Accessing Venus OS from behind NGINX proxy

This is a continuation of original topic from here: https://communityarchive.victronenergy.com/questions/132669/nginx-reverse-proxy.html

You may have various reasons why to put your GX device behind a proxy. For example to shield it from the internet or put it in a DMZ and limit what ports can be accessed and from where.

The original topic contained instructions for Venus OS versions up to 3.33 but started having problems from Venus OS 3.42 and will not work for upcoming version of Venus OS 3.50.

So here I am dropping updated nginx config.

Note: Replace A.B.C.D with the IP of your GX device.

Tip: You can drop the /websockify path from the proxy config once you switch to GUI-v2. The /websockify path is required only for GUI-v1.

Here is the config file that you typically place (on Debian, Ubuntu, Raspberry) somewhere inside /etc/nginx/sites-enabled/ where it is included by default via master /etc/nginx/nginx.conf file.

Note: The config file still uses plain http over port 80. If you enable Venus OS Secure Profile you will have to modify the file accordingly… leaving this as a home work for next time

server {
    listen 80;
    listen [::]:80;
 
    location / {
        proxy_set_header Host $http_host;
        proxy_pass http://A.B.C.D:80;
   }

    location ~ ^/websockify$ {
        proxy_pass http://A.B.C.D:80;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
    }

    location ~ ^/websocket-mqtt$ {
        proxy_pass http://A.B.C.D:80;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
    }
}

Thanks for the update. I tried for weeks to get this work on a subdomain of m website from ubuntu server standing next to victron venus GX. Is it possible to display the venus userinterface on my subdomain, and should I put the code in sites-available or still in sites-enabled. I only got the loading site of venus until now.