Problem with nginx reverse proxy headers

Hello

I am trying to set up external access to my HA. The problem is that my Virgin router port-forwards its public IP address rather than the domain name I access it from. HA doesn’t like this and I get “Error: Invalid client id”.

The port-forward is to an nginx server on a spare RPi (so not on the HA RPi). This is configured as a reverse proxy to my Home Assistant. It works fine internally: if I go directly to my nginx server, I get HA as expected with the hostname of the nginx server being displayed rather than homeassistant.

But when I try to use it from the web it fails because HA is receiving my external IP address and not my domain name from my router. HA doesn’t work with external IP addresses and so I get that error (or so I believe).

I logged the incoming headers on the nginx server and I can see 2 places that have the public IP address and none that have the domain name:

Host: 12.34.56.78
Origin: http://12.34.56.78

I have tried setting those in the reverse proxy but it doesn’t help.

My nginx config is:


        listen 80 default_server;
        proxy_buffering off;

        location / {
                proxy_pass http://homeassistant.local:8123/;
                proxy_set_header        Origin  http://mydomain.net;
                proxy_set_header        Host            mydomain.net;
#            proxy_redirect          http://         https://;
                proxy_set_header        Authorization   $http_authorization;
                proxy_pass_header       Authorization;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection “upgrade”;
        }
    }

Does anyone know the correct way for me to replace the IP address with the domain name? Or that my diagnosis is incorrect?

Thanks

Steve

The problem turned out to be what I’d set in my DNS records at my ISP. So many moving parts! All good now.