目前,我已經成功安裝了apache2.4.18,其中包含mod_proxy_wstunnel並在另一臺機器上安裝了tomcat7。我已經在tomcat7上部署了大氣示例應用程序。然後我可以訪問http://tomcatserver.com:8080/ademo/index.html如何在Apache 2.4.18和tomcat7上設置websocket?
該index.html檢索自https://github.com/Atmosphere/atmosphere-samples/blob/master/samples/chat/src/main/webapp/index.html。
然後我嘗試在下面的apache服務器中設置httpd.conf。我沒有使用任何VirtualHost相關的配置。我只在這個httpd.conf文件的末尾追加下面兩行。
ProxyPass /ademo/ http://tomcatserver.com:8080/ademo/
ProxyPassReverse /ademo/ http://tomcatserver.com:8080/ademo/
然後我重新啓動httpd,並訪問下面的url。 http://apachehttpdserver.com/ademo/index.html
我捕捉到下面的瀏覽器快照,我可以發現websocket不支持。
所以我想知道我怎麼能修改此的httpd.conf支持WebSocket的? 我已取消註釋LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
實際上,我打算設置多個後端服務器,因此我使用下面的配置參考http://blog.arungupta.me/load-balance-websockets-apache-httpd-techtip48/。但我仍然收到錯誤[Fri Jan 08 02:55:50.840362 2016] [proxy:warn] [pid 18446:tid 46971298007360] [client 10.248.66.148:52033] AH01144:沒有協議處理程序對URL/ademo有效/socket.html。如果您使用的是mod_proxy的DSO版本,請確保代理子模塊包含在使用LoadModule的配置中。 我確定的一件事是我已經在httpd.conf中設置了必要的模塊。
<Proxy balancer://mycluster>
# Define back-end servers:
# Server 1
BalancerMember ws://10.214.49.65:8080
# Server 2
BalancerMember ws://10.214.49.83:8080/
</Proxy>
ProxyPass /ademo balancer://mycluster/ademo
ProxyPassReverse /ademo balancer://mycluster/ademo