lua-resty-core icon indicating copy to clipboard operation
lua-resty-core copied to clipboard

Unix sockets work but are not documented

Open JakSprats opened this issue 8 years ago • 1 comments

The following configuration using a unix socket as the current peer works, but it is not documented.

Adding the line: local ok, err = balancer.set_current_peer('some_unix_socket_name'); would suffice

http { upstream backend { server 0.0.0.1; # just an invalid address as a place holder balancer_by_lua_block { local balancer = require "ngx.balancer" local suname = 'unix:/tmp/nginx_socket'; local ok, err = balancer.set_current_peer(suname); if not ok then ngx.log(ngx.ERR, "failed to set the current peer: ", err) return ngx.exit(500) end } } server { listen 8080; location /S/ { proxy_pass http://backend/S/; } } server { listen unix:/tmp/nginx_socket; location /S/__debug { content_by_lua_file ./locations/debug; } }

JakSprats avatar May 13 '16 20:05 JakSprats

@JakSprats I guess it is untested too ;) Patches welcome! (For both docs and tests :)) Thanks!

agentzh avatar May 13 '16 21:05 agentzh