[英]Apache mod_proxy_uwsgi and unix domain sockets
我有一个为 unix 域套接字运行的 uwsgi 服务器
[uwsgi]
...
socket = /var/run/someuwsgi.sock
socket = localhost:9987
...
mod_proxy_uwsgi 已安装
在 apache 配置中有这一行:ProxyPass /some uwsgi://localhost:9987
它正在发挥作用。
问题:通过 unix 域套接字 /var/run/someuwsgi.sock 的 apache 配置行应该是什么? 我试过
ProxyPass /some uwsgi:///var/run/someuwsgi.sock
并得到
Bad Request
Your browser sent a request that this server could not understand.
也试过
ProxyPass /some uwsgi://unix:///var/run/someuwsgi.sock
并得到
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:
谢谢!
从Apache 2.4.7开始 ,增加了对Unix套接字的支持。 语法非常简单:
ProxyPass / unix:/tmp/uwsgi.sock|uwsgi://
不幸的是,apache proxy api(目前)不支持unix套接字
从对另一个答案的评论和我的经验来看,这似乎是正确的语法:
ProxyPass /some unix:/var/run/someuwsgi.sock|uwsgi://localhost
https://httpd.apache.org/docs/trunk/en/mod/mod_proxy.html#proxypass
在 2.4.7 及更高版本中,可以通过使用预先设置 unix:/path/lis.sock| 的目标来支持使用 Unix 域套接字。 例如,要代理 HTTP 并将 UDS 定位在 /home/www.socket,您可以使用 unix:/home/www.socket|http://localhost/whatever/。 由于套接字是本地的,所使用的主机名(在本例中为 localhost)没有实际意义,但它作为请求的 Host: 标头值传递。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.