我正在尝试使用apache设置代理,以便在我的nodejs应用程序中使用socket.io。但是客户端显示以下错误信息:
WebSocket connection to 'wss://example.com/tools/socket.io/?EIO=3&transport=websocket&sid=eOGwJSC14TTWhHRMAAAR' failed: Error during WebSocket handshake: Unexpected response code: 400
这是我的Apache配置:
<VirtualHost *:443>
ServerName example.com
ServerAlias example.com
#SSLRequireSSL
SSLProtocol all -SSLv2 -SSLv3
SSLCompression off
SSLHonorCipherOrder on
SSLEngine on
SSLCertificateFile /etc/ssl/main.pem
SSLCertificateKeyFile /etc/ssl/dec_ssl.key
SSLCertificateChainFile /etc/ssl/sub.class1.server.ca.pem
SSLCACertificateFile /etc/ssl/main.pem
SSLProxyEngine On
ProxyPreserveHost On
ProxyRequests off
</VirtualHost>
<Location /tools/>
ProxyPass http://localhost:8181/
ProxyPassReverse http://localhost:8181/
</Location>
这里是客户端代码:
socket = io.connect("https://example.com",{path:'/tools/socket.io'});
socket.on("connect", function () {
console.log("socketio Connected to server!");
});
我需要添加什么内容到Apache配置中才能消除这个错误?
编辑:我的Apache版本:服务器版本:Apache/2.4.6(CentOS)