簡體   English   中英

如何通過 unix 套接字將 HTTP 和 Websockets 從 Apache 代理到 Gunicorn?

[英]How to proxy HTTP and Websockets from Apache to Gunicorn over unix sockets?

我的安裝程序已經在我的虛擬主機中使用這兩行通過 TCP 工作:

ProxyPassMatch ^/ws/.*$ ws://localhost:8000/
ProxyPass / http://localhost:8000/

現在我想使用unix套接字。 所以我在unix:$SOCKETPATH|前面unix:$SOCKETPATH| 並刪除了端口:

ProxyPassMatch ^/ws/.*$ unix:/run/myapp.sock|ws://localhost/
ProxyPass / unix:/run/myapp.sock|http://localhost/

它適用於 HTTP,但 websocket 連接失敗。 我在 websockets 行中嘗試了右側的變體,例如:

ProxyPassMatch ^/ws/.*$ unix:/run/myapp.sock|ws:///
ProxyPassMatch ^/ws/.*$ unix:/run/myapp.sock|ws://

除了讓它工作之外,我想了解為什么仍然需要管道 (|) 后面的部分? 畢竟,Apache 應該只需要知道 unix 套接字路徑,不是嗎? ProxyPass上的Apache 文檔沒有解釋這一點。

這些類似的問題沒有幫助:

我將 Debian Apache 數據包從 2.4.38-3+deb10u4(穩定)升級到 2.4.46-4~bpo10+1(反向移植),現在它可以工作了。 Apache 更改日志提到了對 websockets 的多項更改。 我想這個變化可能是問題所在:

mod_proxy_wstunnel: Leave Upgrade requests handling to mod_proxy_http,
allowing for (non-)Upgrade negotiation with the origin server.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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