'HTTPD configuration to proxy secure websocket

I'm working on a project contained in a local network. I need to provide access to a web interface within the LAN from outside. Naturally I have setup a proxy and managed to access the interface.

The problem is that the interface uses a web socket to connect to a service and I can't find the good configuration.

Some details :

  • I don't have control of the web interface port
  • The websocket is a secure one (wss)
  • Required modules are loaded (proxy, wstunnel)

Here is my httpd

Listen IP:443
<VirtualHost *:443>
    RewriteEngine On
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteCond %{HTTP:Connection} pgrade [NC]
    RewriteRule .* wss://backendHostname:PORT/UI$1 [P,L]
    SSLProxyEngine On
    SSLProxyCheckPeerCN Off
    SSLProxyCheckPeerName Off
    SSLProxyVerify none
    ProxyPreserveHost On
    ProxyPass / https://backendHostname:PORT/
    ProxyPassReverse / https://backendHostname:PORT/
    ProxyRequests off
    SSLEngine on
    SSLCertificateFile /etc/pki/httpd/httpd.crt
    SSLCertificateKeyFile /etc/pki/httpd/httpd.key
</VirtualHost>
    

I used the Rewrite rule to proxy the websocket but I still get this error

Firefox can’t establish a connection to the server at wss://ProxyIP/UI_WebSocket?ulc=&size=1920x930&lang=en-US

If anyone got ideas to correctly proxy the websocket



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source