1

I'm trying to proxy websockets through Apache 2.4. I found an online demo, and this is my config based off of it. I'm running an app that uses websockets on port 8089 and am using apache to proxy the site and the app.

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerAlias mysitehere

        RewriteEngine on
        RewriteCond %{HTTP:Upgrade} websocket [NC]
        RewriteCond %{HTTP:Connection} upgrade [NC]
        RewriteRule .* "ws://mysiteishere/$1" [P,L]

        ProxyPass / http://0.0.0.0:8089/
        ProxyPassReverse / http://0.0.0.0:8089/
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

The HTTP proxy works fine, but the websockets just seem to hang up and not connect. How could I fix this? All modules needed are installed and apache shows no abnormal errors.

5
  • 0.0.0.0 is a non-routable IP adress, you can't use it to proxy your ws server. Please add the output of netstat -tulpen | grep 8089 to check if the server is running on the same host.
    – digijay
    Oct 31, 2021 at 18:47
  • tcp6 0 0 :::8089 :::* LISTEN 0 14304322 28562/MovieNight
    – x43
    Oct 31, 2021 at 19:09
  • Should I listen on my public IPv4 address?
    – x43
    Oct 31, 2021 at 19:09
  • I am not sure about your config. But first, make sure the following apache modules are loaded: proxy, proxy_http and proxy_wstunnel
    – Chris
    Nov 1, 2021 at 10:53
  • They are all enabled.
    – x43
    Nov 1, 2021 at 15:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.