Add abstract socket support on Linux

This adds abstract socket support for Linux, making it possible
to do for example:

server {
    listen unix:@abstract-socket;

    location / {
        content_by_lua_block {
            ngx.say("hello from @abstract-socket")
        }
    }

    location /abstract-socket {
        content_by_lua_block {
            local sock = ngx.socket.tcp()

            local ok, err = sock:connect("unix:@abstract-socket")
            if not ok then
                return ngx.say("could not connect: ", err)
            end

            ok, err = sock:send("GET /\r\n");
            if not ok then
                return ngx.say("failed to send data on socket")
            end

            ngx.say(sock:receive())
        }
    }
}

echo -en "GET /abstract-socket\r\n" | \
    socat abstract-connect:abstract-socket -
This commit is contained in:
Bjørnar Ness
2018-08-31 14:15:18 +02:00
committed by jiahao
parent d84bf6756d
commit 9418bf69d9
3 changed files with 199 additions and 0 deletions

View File

@ -394,6 +394,13 @@ if [ "$answer" = "N" ]; then
echo
fi
answer=`$root/util/ver-ge "$main_ver" 1.13.6`
if [ "$answer" = "Y" ]; then
echo "$info_txt applying the linux_abstract_sockets patch for nginx"
patch -p1 < $root/patches/nginx-$main_ver-linux_abstract_sockets.patch || exit 1
echo
fi
if [ "$main_ver" = "1.9.7" ]; then
echo "$info_txt applying the resolver_security_fixes patch for nginx"
patch -p1 < $root/patches/nginx-$main_ver-resolver_security_fixes.patch || exit 1