简体   繁体   English

Apache mod_proxy_uwsgi 和 unix 域套接字

[英]Apache mod_proxy_uwsgi and unix domain sockets

I have a uwsgi server running for unix domain socket我有一个为 unix 域套接字运行的 uwsgi 服务器

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

The mod_proxy_uwsgi is installed mod_proxy_uwsgi 已安装

In apache config has that line: ProxyPass /some uwsgi://localhost:9987在 apache 配置中有这一行: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 ?问题:通过 unix 域套接字 /var/run/someuwsgi.sock 的 apache 配置行应该是什么? 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. 从Apache 2.4.7开始 ,增加了对Unix套接字的支持。 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 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|.在 2.4.7 及更高版本中,可以通过使用预先设置 unix:/path/lis.sock| 的目标来支持使用 Unix 域套接字。 For example, to proxy HTTP and target the UDS at /home/www.socket, you would use unix:/home/www.socket|http://localhost/whatever/.例如,要代理 HTTP 并将 UDS 定位在 /home/www.socket,您可以使用 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.由于套接字是本地的,所使用的主机名(在本例中为 localhost)没有实际意义,但它作为请求的 Host: 标头值传递。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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