我已经使用以下指令在 CentOS 版本 5 上为 Tomcat (6.0.26) 配置了一个 Apache(httpd 版本 2.2)服务器作为代理。不幸的是,每个请求都会超时。我检查了 httpd 和 tomcat 日志,没有错误。任何人都知道什么可能是错的?谢谢。
ProxyPass /ws-app http://xxx.xxx.xxx.xxx:8080/ws-app
ProxyPassReverse /ws-app http://xxx.xxx.xxx.xxx:8080/ws-app
当我输入 url -- http://xxx.xxx.xxx.xxx/ws-app/user/list
时,我希望有一个 xml 格式的用户数组。不幸的是,我得到了:
The connection has timed out
The server at xxx.xxx.xxx.xxx is taking too long to respond.
最佳答案
代理连接到 Tomcat HTTP 连接器的情况非常少见。为什么不使用 AJP 连接器?这将带来更多的性能!
确保你的 server.xml
中有这个:
<Connector port="8009" redirectPort="8443" protocol="AJP/1.3" />
然后安装mod_proxy_ajp
并使用以下配置:
ProxyPass /ws-app ajp://xxx.xxx.xxx.xxx:8009/ws-app
ProxyPassReverse /ws-app ajp://xxx.xxx.xxx.xxx:8009/ws-app
同时请检查与远程主机上端口 8009 的连接是否被防火墙阻止。
关于Tomcat 的 Apache (httpd) 代理不断超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4120367/