Websocket fails behind apache proxy

Hi Kyle,
Thanks for the super fast answer, much appreciated. I checked the logs and the headers were actually passed through just fine. So I spent a couple of hours yesterday to try a lot of different configs and finally found one that works (I should probably switch to nginx at one point).
In case anyone else has this issue here’s what worked for me in the end:

  RewriteEngine On
  ProxyPreserveHost On
  ProxyRequests Off

  # allow for upgrading to websockets
  RewriteEngine On
  RewriteCond %{HTTP:Upgrade} =websocket [NC]
  RewriteRule /(.*)           ws://127.0.0.1:8098/$1 [P,L]
  RewriteCond %{HTTP:Upgrade} !=websocket [NC]
  RewriteRule /(.*)           http://127.0.0.1:8098/$1 [P,L]

  ProxyPass / http://127.0.0.1:8098/
  ProxyPassReverse / http://127.0.0.1:8098/

  ProxyPass /notifications/hub ws://127.0.0.1:8098/notifications/hub
  ProxyPassReverse /notifications/hub ws://127.0.0.1:8098/notifications/hub

Not sure if this is the most elegant config but at least it works.

Thanks again, Kyle and also thank you for this amazing password manager.

1 Like