Score:1

Apache2 websocket proxy fails

us flag
x43

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.

digijay avatar
mx flag
`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.
x43 avatar
us flag
x43
`tcp6 0 0 :::8089 :::* LISTEN 0 14304322 28562/MovieNight`
x43 avatar
us flag
x43
Should I listen on my public IPv4 address?
Chris avatar
it flag
I am not sure about your config. But first, make sure the following apache modules are loaded: `proxy`, `proxy_http` and `proxy_wstunnel`
x43 avatar
us flag
x43
They are all enabled.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.