0

I'm using Tailscale and an nginx reverse proxy to access my Home Assistant server. The following nginx.conf snippet works fine:

location / {
    proxy_pass http://home-hassio:8123;

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header X-Real-IP $remote_addr;
}

However, I run into a problem at boot time - since Nginx loads before Tailscale, it fails because it can't get the IP address of the home-hassio host. Based on various sources, I introduced a variable to evaluate the domain IP at runtime. However, the following doesn't work at all.

location / {
    resolver 100.100.100.100;
    resolver_timeout 1s;
    set $upstream http://home-hassio:8123;
    proxy_pass $upstream;

    proxy_http_version 1.1;
    proxy_set_header upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header X-Real-IP $remote_addr;
}

But now, I'm getting 502 Bad Gateway error. What am I doing wrong?

Vladan
  • 725
  • 8
  • 13

0 Answers0