How to configure Apache2 with Phoenix using websockets?

Hello,

I’m trying to configure Apache2 with Phoenix using websockets. I’ve tried a few things and have also been through Websocket reverse proxy with apache2 but still cannot get a working configuration.

Any helpful links or hints would be greatly appreciated.

Thanks,

Jeff

This worked for me

<VirtualHost *:80>
    ServerName myserver.com

   RewriteEngine on
   RewriteCond %{HTTP:Upgrade} websocket [NC]
   RewriteCond %{HTTP:Connection} upgrade [NC]
   RewriteRule ^/?(.*) "ws://localhost:4000/$1" [P,L]

   ProxyPass        /socket/ ws://localhost:4000/socket/
   ProxyPassReverse /socket/ ws://localhost:4000/socket/

   ProxyPass        /live/ ws://localhost:4000/socket/
   ProxyPassReverse /live/ ws://localhost:4000/socket/

   ProxyPass        / http://localhost:4000/
   ProxyPassReverse / http://localhost:4000/

</VirtualHost>
1 Like