根据 apaches文档,wstunnel 是在 2.4 中添加的,我应该能够路由流量。
我有以下设置
运行在 8081 和 8444 上的 Apache tomcat。
Tomcat 提供静态文件 (html/js) 以及 groovy/grails (war) 文件
我已经代理了8081 <- 80
和 8444 <- 443
意思是我可以转到http://domain/app
看看我必须去http://domain:8081/app
查看。 [这工作得很好]
但是,在静态 javascript/html 页面中,有一个使用 websocket 返回到 tomcat 的连接。我的应用程序尝试连接回名为 inf
的应用程序这失败了。
此代理/连接失败。
我在日志中看到 httpd (apache) 无法为 /inf/stomp/getInfo
找到正确的协议(protocol)这是后端 websocket 的 url
我试图关注 this posts this post 中提到的注意事项以及正确的顺序
httpd.conf
Listen 443
ServerName mydomain
<VirtualHost *:443>
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
SSLEngine On
SSLProxyEngine On
SSLCertificateFile /etc/httpd/ssl/ssl.crt
SSLCertificateKeyFile /etc/httpd/ssl/ssl.key
RequestHeader set Front-End-Https "On"
SSLProxyEngine on
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
LogLevel debug
ProxyPass /mainView https://mydomain:8443/mainView
ProxyPassReverse /mainView https://mydomain:8443/mainView
ProxyPass /cas https://mydomain:8443/cas
ProxyPassReverse /cas https://mydomain:8443/cas
# <not working as it should>
ProxyPass /inf/ ws://mydomain:8081/inf/
ProxyPassReverse /inf/ ws://mydomain:8081/inf/
# </not working as it should>
ProxyPass /inf/ wss://mydomain:8444/inf/
ProxyPassReverse /inf/ wss://mydomain:8444/inf/
ProxyPass /inf-app https://mydomain:8444/
ProxyPassReverse /inf-app https://mydomain:8444/
</VirtualHost>
最佳答案
您是否意识到您有两个:ProxyPass/inf/ block ,如果您同时拥有安全和不安全的 virtualHost,则需要将 ws: 版本移动到端口 80 虚拟主机。还有一个重复的 SSLProxyEngine on
关于解决您的问题,请参阅:tunneling secure websocket connections with apache ,特别是:--enable-proxy_wstunnel=shared text
关于apache - 使用 apache web 服务器代理到 apache tomcat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32276302/