gpt4 book ai didi

apache2 - 使用 websocket mod_proxy_wstunnel 进行反向代理

转载 作者:行者123 更新时间:2023-12-04 01:39:59 24 4
gpt4 key购买 nike

我的 Web 套接字和我的反向代理 Apache 有问题,我已经升级到最新版本 2.4.5 并加载了模块 mod_proxy_wstunnel .

httpd.conf :

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName www.toto.fr
ServerAlias toto.fr


ProxyPass /my_app http://1X.X.X.1:8080/my_app
ProxyPassReverse /web_pmr http://1X.X.X.1:8080/my_app
ProxyPassReverseCookiePath /my_app /
ProxyPassReverseCookieDomain localhost my_app
ProxyRequests off
ProxyTimeout 15

#WEBSOCKETS


ProxyPass /my_app/BasicWebsocketServlet ws://1X.X.X.1:8080/my_app/BasicWebsocketServlet retry=0
ProxyPassReverse /my_app/BasicWebsocketServlet ws://1X.X.X.1:8080/web_pmr/BasicWebsocketServlet retry=0


ErrorLog "logs/my_app_error.log"
LogLevel debug
CustomLog "logs/my_app_access.log" combined
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>

当我在本地 URL 中进行测试时,websockets 正在工作,但使用反向代理 Apache,Tomcat 日志中没有任何痕迹。

最佳答案

这一行:

ProxyPass /my_app/BasicWebsocketServlet ws://1X.X.X.1:8080/my_app/BasicWebsocketServlet retry=0
需要在这个之前:
ProxyPass /my_app  http://1X.X.X.1:8080/my_app
解释(来自 https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypass ):

Ordering ProxyPass Directives

The configured ProxyPass and ProxyPassMatch rules are checked in the order of configuration. The first rule that matches wins. So usually you should sort conflicting ProxyPass rules starting with the longest URLs first. Otherwise later rules for longer URLS will be hidden by any earlier rule which uses a leading substring of the URL. Note that there is some relation with worker sharing. In contrast, only one ProxyPass directive can be placed in a Location block, and the most specific location will take precedence.

For the same reasons exclusions must come before the general ProxyPass directives.

关于apache2 - 使用 websocket mod_proxy_wstunnel 进行反向代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17649241/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com