簡體   English   中英

Apache mod_proxy_uwsgi 和 unix 域套接字

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM