nginx-proxy-manager icon indicating copy to clipboard operation
nginx-proxy-manager copied to clipboard

FIX: Ngnix fails to start if upstream host for stream is unavailable/unreachable

Open kabadisha opened this issue 2 years ago • 8 comments

Issue:

Currently, if the upstream host being forwarded to is down, Nginx fails to start. Reported by @StefaBa here: https://github.com/NginxProxyManager/nginx-proxy-manager/pull/2672#issuecomment-1475361687

Impact:

In this scenario:

  • All other hosts managed by NPM are now also taken out.
  • NPM cannot be started in order to disable or edit the host configuration in order to rectify the issue.

Solution:

Declare a variable for forwarding_host instead of simply injecting it directly into the proxy_pass directive. Use variables for proxy_pass directive in order to prevent startup failure if the upstream host is down.

@StefaBa this one is for you. I think it should work, but I don't use this functionality, so can you please test it?

kabadisha avatar Mar 19 '23 20:03 kabadisha

FYI: There are actually only a couple of functionally changed lines. Most of the change is indentation which I added to make the code easier for me to read.

kabadisha avatar Mar 19 '23 20:03 kabadisha

npm still fails to start, here's a pastebin of the startup log: https://pastebin.com/XW8z4GLK

fwiw: newhost.wan.vm is currently not only offline, but also unknown to the local DNS server. -> nslookup newhost.wan.vm currently yields:

** server can't find newhost.wan.vm: NXDOMAIN

with newhost.wan.vm being offline, but known to the local DNS server NPM does come online (both with the current :latest version and with :github-pr-2714)

StefaBa avatar Mar 19 '23 21:03 StefaBa

Can you share what 3.conf looks like?

kabadisha avatar Mar 19 '23 21:03 kabadisha

here you go: https://pastebin.com/eufsKe7W

i since tried recreating this stream in :github-pr-2714, but that always shows the stream as "Offline" in the web-ui, even when newhost.wan.vm is online.

edit: the pastebin is the original 3.conf, generated by :latest recreating the stream in :latest and then using it in :github-pr-2714 shows the stream as "Online" in both :latest and :github-pr-2714. (as long as newhost.wan.vm is online)

StefaBa avatar Mar 19 '23 21:03 StefaBa

Sorry, I should have been more specific - I wanted to see 3.conf generated by :github-pr-2714 to make sure I didn't screw something up. I think it should look something like this:

# ------------------------------------------------------------
# 40173 TCP: 0 UDP: 1
# ------------------------------------------------------------

set $forwarding_host newhost.wan.vm;
set $forwarding_port 40173;

server {
  listen 40173 udp;
#listen [::]:40173 udp;
 
  proxy_pass $forwarding_host:$forwarding_port;
 
  # Custom
  include /data/nginx/custom/server_stream[.]conf;
  include /data/nginx/custom/server_stream_udp[.]conf;
}

It's possible that I should have included the set declarations inside the server block (I'm not super hot on Nginx variable scoping), but I think it should work as it is.

kabadisha avatar Mar 19 '23 23:03 kabadisha

PR is now considered stale. If you want to keep it open, please comment :+1:

github-actions[bot] avatar Apr 16 '24 01:04 github-actions[bot]

CI Error:

/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
certbot-node: Pulling from nginxproxymanager/nginx-full
Digest: sha256:eaa2ebcb50dd87557c9a8f95a3230128d94cac1ea17800261c036e59378e7d49
Status: Image is up to date for nginxproxymanager/nginx-full:certbot-node
docker.io/nginxproxymanager/nginx-full:certbot-node
[1;34m❯ [1;36mBuilding Frontend ...[0m
yarn install v1.22.22
[1/4] Resolving packages...
[2/4] Fetching packages...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error Command failed.
Exit code: 128
Command: git
Arguments: clone https://github.com/tabler/tabler.git /usr/local/share/.cache/yarn/v6/.tmp/e11a93799a52aa978c82015e29fbe309
Directory: /app/frontend
Output:
Cloning into '/usr/local/share/.cache/yarn/v6/.tmp/e11a93799a52aa978c82015e29fbe309'...
error: RPC failed; curl 92 HTTP/2 stream 5 was not closed cleanly: CANCEL (err 8)
error: 512 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output

PR is now considered stale. If you want to keep it open, please comment :+1:

github-actions[bot] avatar Jun 11 '25 02:06 github-actions[bot]