尝试我的运气她的StackOverflow不是正确的地方问。 希望这是我的问题所在!
最近几天,我一直在拉我的头发,使websocket与Apache2.4一起工作。 我终于find了适合我的解决scheme,即:
<VirtualHost *:80> ServerName www.domain2.com RewriteEngine On RewriteCond %{REQUEST_URI} ^/socket.io [NC] RewriteCond %{QUERY_STRING} transport=websocket [NC] RewriteRule /(.*) ws://localhost:3001/$1 [P,L] ProxyPass / http://localhost:3001/ ProxyPassReverse / http://localhost:3001/ </VirtualHost>
问题? 那么,只要我切换到wss,我是不走运的。 起初,我希望能够把ws改成wss以上,但是这并没有办法,我仍然得到了一个500错误。 我可能会错过什么? (我使用socket.io,请求如下所示: wss://xxx.yy/socket.io/?auth=YYY&EIO=3&transport=websocket&sid=XXX
我最近有几乎完全相同的问题。 它与HTTP和WS一起工作,但是当我切换到HTTPS和WSS时,它停止工作。 我摆弄了一下,并以某种方式使它工作。 这是我的工作configuration:
<VirtualHost *:443> ServerName blabla #SSL-stuff ... # I don't think this is important but it's there <Proxy *> Order deny,allow Allow from all </Proxy> # Here's the fun stuff <Location /> RewriteEngine on RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC] RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC] RewriteRule .* ws://localhost:3002%{REQUEST_URI} [P,L] ProxyPass http://localhost:3001/ ProxyPassReverse http://localhost:3001/ </Location> </VirtualHost>
和你的没有什么不同 它不是查找websocket的path和查询string,而是查找HTTP请求中的Upgrade和Connection标头,这表明这应该成为websocket。
URL和查询参数将由您的应用程序处理
我很抱歉,我不能确切地告诉你什么是错的,但希望我的configuration也能适用于你的情况