user27815
user27815

Reputation: 4797

apache websockets reverse proxy

How do I get Apache to reverse proxy web socket connections?

I have a chat room application that works fine on the local host but not for connections through the reverse proxy.

How do I set this up so that it will work?

<VirtualHost *:80>
    ServerAdmin [email protected]
    ProxyRequests off
    DocumentRoot /var/www

    ProxyPreserveHost On


    ServerName 82.2.180.6

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


    LogLevel error
    <Location />
     ProxyPass http://127.0.0.1:3050/
     ProxyPassReverse http://127.0.0.1:3050/
     Order allow,deny
     Allow from all
    </Location>

</VirtualHost>

Upvotes: 1

Views: 1785

Answers (1)

lysc507
lysc507

Reputation: 58

Yes, its possible. We have used Apache to reverse proxy websocket.

Make sure that your Apache is built with the module: mod_proxy_wstunnel. Which is supported after Version 2.4.5.

Then you just need to find out which port for your websocket is using.

If it is also using 3050, then you need something like this:

LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so

#***SKIPPED OTHER HTTPD CONFIG***

   <Location />
        ProxyPass ws://127.0.0.1:3050/
        ProxyPassReverse ws://127.0.0.1:3050/
   </Location>

Upvotes: 3

Related Questions