【问题标题】:How to proxy HTTP and Websockets from Apache to Gunicorn over unix sockets?如何通过 unix 套接字将 HTTP 和 Websockets 从 Apache 代理到 Gunicorn?
【发布时间】:2021-09-06 07:58:56
【问题描述】:

我的安装程序已经通过 TCP 在我的虚拟主机中使用这两行:

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

现在我想使用 unix 套接字。所以我在前面加上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 套接字路径,不是吗? Apache documentation on ProxyPass 没有解释这一点。

这些类似的问题没有帮助:

【问题讨论】:

    标签: apache httpd.conf mod-proxy unix-socket mod-proxy-wstunnel


    【解决方案1】:

    我将 Debian Apache 数据包从 2.4.38-3+deb10u4 (stable) 升级到 2.4.46-4~bpo10+1 (backports),现在它可以工作了。 Apache 更改日志提到了对 websockets 的多项更改。我想这个变化可能是问题所在:

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

    【讨论】:

      猜你喜欢
      • 2017-02-04
      • 2012-02-29
      • 1970-01-01
      • 2016-07-31
      • 2015-03-14
      • 2013-11-23
      • 1970-01-01
      • 2014-07-18
      • 1970-01-01
      相关资源
      最近更新 更多