Apache with ProxyPass and Websockets

Hi!

I’ve seen that some people having troubles with this, but nobody was really able to solve it.

I’m currently trying to host two applications with Websockets using Hestia. I’m using Apache as a web server and have configured the recommended settings according to the applications’ documentations for the two websites.

The applications are run using docker.

The configuration looks like this:

<Location /audiobookshelf>
    ProxyPreserveHost on
    ProxyPass http://localhost:8090/audiobookshelf
    ProxyPassReverse http://localhost:8090/audiobookshelf
</Location>
<Location /audiobookshelf/socket.io>
    ProxyPreserveHost on
    ProxyPass ws://localhost:8090/audiobookshelf/socket.io upgrade=websocket
    ProxyPassReverse ws://localhost:8090/audiobookshelf/socket.io
</Location>

I’ve enabled the required Apache modules and even tried to use the modern ProxyPass upgrade=websocket-Solution but nothing works.

Is there anything global that Hestia configures in Apache that might break Websockets, because I’d think that if BOTH applications fail to work even if configured as documented it might be something else.

Thanks!

Kind regards
Dennis

Ohhhh! Now I get it.

Hestia also adds an Nginx in front of the Apache. I wasn’t aware of that.

And the Nginx doesn’t properly forward the websocket.

I’ve added another nginx template and configured the / location like this:

location / {
                proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto  $scheme;
                proxy_set_header Host               $http_host;

                proxy_set_header Upgrade            $http_upgrade;
                proxy_set_header Connection         "upgrade";

                proxy_http_version                  1.1;

                proxy_pass https://%ip%:%web_ssl_port%;

Now it apparently forwards the request to apache, but together with my configuration about, I get an 101 status code back now, which doesn’t seem to be correct either.

Does somebody know how to fix this as well?

OR: Is it possible to deactivate the Nginx and just use Apache in Hestia?

1 Like

Found it. There was a line “proxy_hide_header Upgrade;” further down below, that needed to be removed. It finally works now! :partying_face:

2 Likes