简体   繁体   中英

Apache mod_proxy_uwsgi and unix domain sockets

I have a uwsgi server running for unix domain socket

[uwsgi]
...
socket = /var/run/someuwsgi.sock
socket = localhost:9987
...

The mod_proxy_uwsgi is installed

In apache config has that line: ProxyPass /some uwsgi://localhost:9987

And it is working.

Question: what should be the apache config line to go through unix domain socket /var/run/someuwsgi.sock ? I tried

ProxyPass /some uwsgi:///var/run/someuwsgi.sock

and got

Bad Request
Your browser sent a request that this server could not understand.

Also tried

ProxyPass /some uwsgi://unix:///var/run/someuwsgi.sock

and got

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /some/.

Reason: DNS lookup failure for: unix:

Thanks!

Starting from Apache 2.4.7 , support for Unix sockets has been added. The syntax is pretty simple:

ProxyPass / unix:/tmp/uwsgi.sock|uwsgi://

不幸的是,apache proxy api(目前)不支持unix套接字

From the comments on the other answer and my experience this seems to be the correct syntax:

ProxyPass /some unix:/var/run/someuwsgi.sock|uwsgi://localhost

https://httpd.apache.org/docs/trunk/en/mod/mod_proxy.html#proxypass

In 2.4.7 and later, support for using a Unix Domain Socket is available by using a target which prepends unix:/path/lis.sock|. For example, to proxy HTTP and target the UDS at /home/www.socket, you would use unix:/home/www.socket|http://localhost/whatever/. Since the socket is local, the hostname used (in this case localhost) is moot, but it is passed as the Host: header value of the request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM