[GH-ISSUE #633] Unavailable host in proxy configuration preventing startup of NPM #535

Closed
opened 2026-02-26 06:33:18 +03:00 by kerem · 4 comments
Owner

Originally created by @Elmardus on GitHub (Oct 5, 2020).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/633

Describe the bug

  • When using a Forward Hostname in the Proxy settings, Nginx Proxy Manager fails to start if this host is unavailable.
  • NPM version 2.5.0

To Reproduce

  1. Setup a Nginx-proxy-manager proxy host with the hostname of a docker container as the Forward Hostname, example shown below:

image

  1. Stop or remove the container with this hostname
  2. Restart NPM

NPM will now fail to start, with the following error log:

❯ Enabling IPV6 in hosts: /etc/nginx/conf.d
  ❯ /etc/nginx/conf.d/default.conf
  ❯ /etc/nginx/conf.d/include/assets.conf
  ❯ /etc/nginx/conf.d/include/ip_ranges.conf
  ❯ /etc/nginx/conf.d/include/letsencrypt-acme-challenge.conf
  ❯ /etc/nginx/conf.d/include/proxy.conf
  ❯ /etc/nginx/conf.d/include/force-ssl.conf
  ❯ /etc/nginx/conf.d/include/ssl-ciphers.conf
  ❯ /etc/nginx/conf.d/include/block-exploits.conf
  ❯ /etc/nginx/conf.d/include/resolvers.conf
  ❯ /etc/nginx/conf.d/production.conf
❯ Enabling IPV6 in hosts: /data/nginx
  ❯ /data/nginx/default_host/site.conf
  ❯ /data/nginx/proxy_host/18.conf
  ❯ /data/nginx/proxy_host/28.conf
  ❯ /data/nginx/proxy_host/7.conf
  ❯ /data/nginx/proxy_host/32.conf
  ❯ /data/nginx/proxy_host/9.conf
  ❯ /data/nginx/proxy_host/24.conf
  ❯ /data/nginx/proxy_host/26.conf
  ❯ /data/nginx/proxy_host/3.conf
  ❯ /data/nginx/proxy_host/25.conf
  ❯ /data/nginx/proxy_host/22.conf
  ❯ /data/nginx/proxy_host/23.conf
  ❯ /data/nginx/proxy_host/31.conf
  ❯ /data/nginx/proxy_host/27.conf
  ❯ /data/nginx/proxy_host/5.conf
  ❯ /data/nginx/proxy_host/4.conf
  ❯ /data/nginx/proxy_host/14.conf
  ❯ /data/nginx/proxy_host/29.conf
  ❯ /data/nginx/proxy_host/1.conf
  ❯ /data/nginx/proxy_host/12.conf
  ❯ /data/nginx/proxy_host/16.conf
  ❯ /data/nginx/proxy_host/6.conf
nginx: [emerg] host not found in upstream "sonarr" in /data/nginx/proxy_host/23.conf:61
finish: applet not found

Operating System

  • Debian Buster, using docker-compose to manage all containers.
Originally created by @Elmardus on GitHub (Oct 5, 2020). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/633 **Describe the bug** - When using a Forward Hostname in the Proxy settings, Nginx Proxy Manager fails to start if this host is unavailable. - NPM version 2.5.0 **To Reproduce** 1. Setup a Nginx-proxy-manager proxy host with the hostname of a docker container as the _Forward Hostname_, example shown below: ![image](https://user-images.githubusercontent.com/25563589/95137987-7fadf700-0769-11eb-8f1a-b83e8336cce1.png) 2. Stop or remove the container with this hostname 3. Restart NPM NPM will now fail to start, with the following error log: ``` ❯ Enabling IPV6 in hosts: /etc/nginx/conf.d ❯ /etc/nginx/conf.d/default.conf ❯ /etc/nginx/conf.d/include/assets.conf ❯ /etc/nginx/conf.d/include/ip_ranges.conf ❯ /etc/nginx/conf.d/include/letsencrypt-acme-challenge.conf ❯ /etc/nginx/conf.d/include/proxy.conf ❯ /etc/nginx/conf.d/include/force-ssl.conf ❯ /etc/nginx/conf.d/include/ssl-ciphers.conf ❯ /etc/nginx/conf.d/include/block-exploits.conf ❯ /etc/nginx/conf.d/include/resolvers.conf ❯ /etc/nginx/conf.d/production.conf ❯ Enabling IPV6 in hosts: /data/nginx ❯ /data/nginx/default_host/site.conf ❯ /data/nginx/proxy_host/18.conf ❯ /data/nginx/proxy_host/28.conf ❯ /data/nginx/proxy_host/7.conf ❯ /data/nginx/proxy_host/32.conf ❯ /data/nginx/proxy_host/9.conf ❯ /data/nginx/proxy_host/24.conf ❯ /data/nginx/proxy_host/26.conf ❯ /data/nginx/proxy_host/3.conf ❯ /data/nginx/proxy_host/25.conf ❯ /data/nginx/proxy_host/22.conf ❯ /data/nginx/proxy_host/23.conf ❯ /data/nginx/proxy_host/31.conf ❯ /data/nginx/proxy_host/27.conf ❯ /data/nginx/proxy_host/5.conf ❯ /data/nginx/proxy_host/4.conf ❯ /data/nginx/proxy_host/14.conf ❯ /data/nginx/proxy_host/29.conf ❯ /data/nginx/proxy_host/1.conf ❯ /data/nginx/proxy_host/12.conf ❯ /data/nginx/proxy_host/16.conf ❯ /data/nginx/proxy_host/6.conf nginx: [emerg] host not found in upstream "sonarr" in /data/nginx/proxy_host/23.conf:61 finish: applet not found ``` **Operating System** - Debian Buster, using docker-compose to manage all containers.
kerem 2026-02-26 06:33:18 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@neojp commented on GitHub (Oct 21, 2020):

I've come across this before with the upstream nginx-proxy image. This is technically a non-solvable nginx problem (this is by design for performance purposes). The host + IP must exist otherwise nginx won't be able to bind it when its service starts.

<!-- gh-comment-id:713434432 --> @neojp commented on GitHub (Oct 21, 2020): I've come across this before with the upstream nginx-proxy image. This is technically a non-solvable nginx problem (this is by design for performance purposes). The host + IP must exist otherwise nginx won't be able to bind it when its service starts.
Author
Owner

@Elmardus commented on GitHub (Oct 21, 2020):

So if I understand correctly, the IP must be available on Nginx service startup?
As discussed in this stackoverflow answer, there is a way to circumvent this issue, but I'm not sure how to implement this in my NPM configuration.

<!-- gh-comment-id:713452867 --> @Elmardus commented on GitHub (Oct 21, 2020): So if I understand correctly, the IP must be available on Nginx service startup? As discussed [in this stackoverflow answer](https://stackoverflow.com/a/54719226), there is a way to circumvent this issue, but I'm not sure how to implement this in my NPM configuration.
Author
Owner

@chaptergy commented on GitHub (May 12, 2021):

The "solution" is hard to implement in a generic way, since the DNS resolver can be a different ip on different hosts (at least the stack overflow answers all name different ips). It should be 127.0.0.11, if you use the custom docker network, but could be anything as soon as you use the bridge or host network. To see which resolver your instance uses, execute cat /etc/resolv.conf inside the container.

NPM is served by the same nginx as the one that proxies your requests, hence both are unavailable if it refuses to start. As running multiple nginx instances is complicated, comes with lots of caveats and would require lots of code changes, I don't think this would be an option.

Since this is not really a bug, but instead an nginx "feature" and it could also be solved using the advanced configuration (which inserts code into the server block) or with a custom location with advanced code, I will close this issue.
For anyone coming here with this issue: Take a look at https://github.com/jc21/nginx-proxy-manager/issues/669#issuecomment-840054181 for the solution.

<!-- gh-comment-id:840023785 --> @chaptergy commented on GitHub (May 12, 2021): The "solution" is hard to implement in a generic way, since the DNS resolver can be a different ip on different hosts (at least the stack overflow answers all name different ips). It _should_ be `127.0.0.11`, if you use the custom docker network, but could be anything as soon as you use the bridge or host network. To see which resolver your instance uses, execute `cat /etc/resolv.conf` inside the container. NPM is served by the same nginx as the one that proxies your requests, hence both are unavailable if it refuses to start. As running multiple nginx instances is complicated, comes with lots of caveats and would require lots of code changes, I don't think this would be an option. Since this is not really a bug, but instead an nginx "feature" and it could also be solved using the advanced configuration (which inserts code into the server block) or with a custom location with advanced code, I will close this issue. For anyone coming here with this issue: Take a look at https://github.com/jc21/nginx-proxy-manager/issues/669#issuecomment-840054181 for the solution.
Author
Owner

@kabadisha commented on GitHub (Mar 12, 2023):

Take a look at #669 (comment) for the solution.

Firstly, thanks @chaptergy for the tip to that other thread with a workaround. Much obliged.

I found that to solve the problem, I didn't actually have to include specifying the resolver. This worked for me:

location / {
    set $custom_upstream example.com;
    proxy_pass http://$custom_upstream:80;
}

This made me wonder about what you said here:

The "solution" is hard to implement in a generic way, since the DNS resolver can be a different ip on different hosts

If the resolver doesn't have to be explicitly defined, couldn't NPM generate the config as per my example, inserting the Forward Hostname using a variable and thus avoid this issue where Nginx won't start if that host is unavailable?

Many thanks :-)

EDIT:
After doing some more digging, this actually explains why we only see the startup failure when an unavailable host is added as a 'Custom Location' in the GUI. When NPM generates the config for the top level, the hostname is inserted using the $server variable, thus avoiding the issue.
However, for custom locations the host entered in the GUI is simply transposed directly into the proxy_pass directive like this: proxy_pass http://example.com;

<!-- gh-comment-id:1465055666 --> @kabadisha commented on GitHub (Mar 12, 2023): > Take a look at [#669 (comment)](https://github.com/NginxProxyManager/nginx-proxy-manager/issues/669#issuecomment-840054181) for the solution. Firstly, thanks @chaptergy for the tip to that other thread with a workaround. Much obliged. I found that to solve the problem, I didn't actually have to include specifying the resolver. This worked for me: ``` location / { set $custom_upstream example.com; proxy_pass http://$custom_upstream:80; } ``` This made me wonder about what you said here: > The "solution" is hard to implement in a generic way, since the DNS resolver can be a different ip on different hosts If the resolver doesn't have to be explicitly defined, couldn't NPM generate the config as per my example, inserting the Forward Hostname using a variable and thus avoid this issue where Nginx won't start if that host is unavailable? Many thanks :-) EDIT: After doing some more digging, this actually explains why we only see the startup failure when an unavailable host is added as a 'Custom Location' in the GUI. When NPM generates the config for the top level, the hostname is inserted using the `$server` variable, thus avoiding the issue. However, for custom locations the host entered in the GUI is simply transposed directly into the proxy_pass directive like this: `proxy_pass http://example.com;`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-proxy-manager-NginxProxyManager#535
No description provided.