Trying my luck her as StackOverflow was not the right place to ask. Hopefully this is where my question belongs!
I have been pulling my hair the last few days getting websockets to work with Apache2.4. I finally found a solution that worked for me, namely the following:
<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>
The problem? Well, as soon as I switch over to wss, I am out of luck. At first, I hoped I could just change ws to wss above, but that didn't do the trick, I still get a 500 error. What might I be missing? (I use socket.io and the request looks like this: wss://xxx.yy/socket.io/?auth=YYY&EIO=3&transport=websocket&sid=XXX
Недавно у меня была почти такая же проблема. Он работал с HTTP и WS, но когда я перешел на HTTPS и WSS, он перестал работать. Я немного повозился, и как-то заставил это работать. Это мой рабочий конфиг:
<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>
Он не сильно отличается от вашего. Вместо того, чтобы искать путь и строку запроса для веб-сокета, он ищет заголовки Upgrade и Connection в HTTP-запросе, который сообщает, что он должен стать веб-сокетом.
URL-адрес и параметры запроса будут обрабатываться вашим приложение
Извините, я не могу точно сказать, что не так, но надеюсь, что моя конфигурация будет работать и в вашем случае