我已經看過this question以及SO和其他相關網站上的其他人,但迄今爲止所提出的解決方案都沒有奏效。如何配置Apache以正確轉發Websockets?
我在localhost:8080
上運行tty.js
,並驗證當直接點擊該端口時websockets正常工作。現在,我試圖通過Apache反向代理連接到tty.js
。該應用程序可以不使用Websockets,但我想了解爲什麼Websockets不起作用。
這是我的Apache配置,用於在localhost
上進行測試,其中包含source的新版Apache版本。
Listen 9000
# Load proxy modules
LoadModule proxy_module "modules/mod_proxy.so"
LoadModule proxy_http_module "modules/mod_proxy_http.so"
LoadModule proxy_wstunnel_module "modules/mod_proxy_wstunnel.so"
<VirtualHost *:9000>
ServerName localhost
ProxyPass /tty/socket.io/1/ ws://localhost:8080/socket.io/1/
ProxyPassReverse /tty/socket.io/1/ ws://localhost:8080/socket.io/1/
ProxyPass /tty/ http://localhost:8080/
ProxyPassReverse /tty/ http://localhost:8080/
</VirtualHost>
當我連接到http://localhost:9000/tty/
,我得到一個500
錯誤。
在服務器端日誌中,出現以下錯誤。
[Mon Jan 02 19:30:32.342551 2017] [proxy:warn] [pid 28226:tid 140098955872000] [client 127.0.0.1:38372] AH01144: No protocol handler was valid for the URL /tty/socket.io/1/. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule., referer: http://localhost:9000/tty/
什麼是正確的配置Apache以使WebSockets的正常工作?