Home assistat websocket with proxy web not working in Firefox

Setup

I have replaced nginx-proxy-manager with virtualmin so I can host some sites/services using a single residential ip address using virtual servers that are served directly from virtualmin.

Homeassistant is not served directly from virtualmin and I’m using vm’s or docker containers to serve homeassistant and other services.

For those advanced services I have a domain name per service and I use virtual server with web proxy enabled to redirect the traffic to each internal ip address.

HTTP   ->  Edge  -> virtualmin -> virtual ->  Web  -[http]-> local-ip:80
HTTPs     router                  server     Proxy

This works well for most http/https traffic.

This works well with websockts for Chrome and Safari, but it fails with websockets with Firefox.

The problem

Firefox is sending a different header for to upgrade the http connection to a websocket and it is not setup correctly on the virtual host in webmin.

Chrome/Safari headers

Connection: Upgrade

Firefox headers

Connection: keep-alive, Upgrade

Default virtual server - Web proxy setup

[...]

ProxyPass /.well-known !
ProxyPass / http://local-ip:3000/
RewriteEngine on
[...]
ProxyPassReverse / http://local-ip:3000/
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule ^/?(.*) "ws://local-ip:3000/$1" [P]

Fixed virtual server - Web proxy setup

Replace the line:

RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]

with the fixed condition to match Firefox headers.

RewriteCond %{HTTP:CONNECTION} "(^|,)\s*upgrade\s*(,|$)" [NC]

Q: How do I update the virtualmin virtual hosts template?

While this gets patched, I would like to update my local templates so every time I create a new virtual server the new rewrite cond are applied correctly.

Where are those templates located?

Note: This issue was previously reported here, but I’m unable to post in that thread.

Thank you,
Albert

SYSTEM INFORMATION
OS type and version Ubuntu Linux 24.04.2
Virtualmin version 7.30.8

You can edit the Apache directives in Server Templates: Virtualmin>System Settings>Server Templates> (select existing, create a new template, or clone existing)>Website for Domain>Directives and settings for new websites.

Make sure you select whether the template will be available for top level or sub-servers accordingly.