'nginx cause ERR_TOO_MANY_REDIRECTS when using variable set $upstream

I do have a very odd phenomenon when configuring nginx as reverse proxy. While the following works just fine

location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass https://host:8443/;
    proxy_ssl_verify off;
}

The next lines of code causing redirection problems (and browser response with ERR_TOO_MANY_REDIRECTS)

location / {
    resolver 127.0.0.11;
    set $us https://buerger:8443/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass $us;
    proxy_ssl_verify off;
}

The reason why I was trying to setup that way using a variable as upstream, is to silently continue the startup of nginx, even when the host is unavailable at startup.

Im using nginx 1.21.6 as docker container



Sources

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

Source: Stack Overflow

Solution Source