apache - 使用 apache web 服务器代理到 apache tomcat

标签 apache tomcat proxy websocket stomp

根据 apaches文档,wstunnel 是在 2.4 中添加的,我应该能够路由流量。

我有以下设置

运行在 8081 和 8444 上的 Apache tomcat。

Tomcat 提供静态文件 (html/js) 以及 groovy/grails (war) 文件

我已经代理了8081 <- 808444 <- 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/

相关文章:

apache - 服务器如何维护 session

c# - 使用 Tor 作为代理

java - 如何减少 WAR 文件大小以部署在 Tomcat 服务器主机上?

java - 如何在 Eclipse 中的 Tomcat 中使用导致 InvalidJarIndexException 的损坏的 JAR 索引来追踪 JAR

java - 我启动 tomcat,我的代码运行良好,但在一段时间后发生通信链接故障异常

node.js - 强制 node.exe 在 Windows 10 上抛出 proxifier

javascript - Express、http-proxy-middleware 和 net::ERR_CONNECTION_REFUSED

ruby-on-rails - Apache2 Passenger(谷歌计算引擎)通过 Ruby 版本捕获 SIGTERM?

ruby-on-rails - 为什么 Apache 还没有可行的 mod_ruby?

Apache 2.2 WebDav 匿名访问