AWS EC2 + NodeJs上的websocket(wss)的Apache错误:" wss没有协议处理程序..."

时间:2018-06-06 20:16:41

标签: node.js apache amazon-ec2 websocket

我们在Elastic Beanstalk上运行NodeJs应用程序并尝试通过Apache代理websocket连接:

<IfModule !proxy_wstunnel_module>
  LoadModule proxy_wstunnel_module /etc/httpd/modules/mod_proxy_wstunnel.so
</IfModule>
<IfModule !deflate_module>
  LoadModule deflate_module /etc/httpd/modules/mod_deflate.so
</IfModule>
<IfModule !headers_module>
   LoadModule headers_module /etc/httpd/modules/mod_headers.so
</IfModule>

ProxyPass         /socket.io/   wss://localhost:2000/socket.io/dist/
ProxyPassReverse  /socket.io/   wss://localhost:2000/socket.io/dist/

我们使用 wss (安全),因为所有流量都在 https 上。

在客户端/浏览器端,我们使用socket.io-client(v2.1.0):

var socket = io(window.location.origin, {
  'transport': [ 'websocket' ],
  'query': '...'
});

在测试此设置时,我在浏览器控制台中看到以下错误:

vendor-0b90174c55.js:1 WebSocket connection to 'wss://app-dev...net/socket.io/?...&transport=websocket'
failed: Error during WebSocket handshake: Unexpected response code: 500

Apache error_log吐出:

AH01144: No protocol handler was valid for the URL /socket.io/ (scheme 'wss').
If you are using a DSO version of mod_proxy, 
make sure the proxy submodules are included in the configuration using LoadModule.

我缺少什么?

如何让websockets在AWS Elastic Beanstalk + NodeJs + Apache上运行?

0 个答案:

没有答案