Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

kabadisha
Copy link

Issue:

Currently, if the upstream host being forwarded to is down, Nginx fails to start.
Reported by @StefaBa here: #2672 (comment)

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?

Use variables for proxy_pass directive in order to prevent startup failure if the upstream host is down.
@kabadisha
Copy link
Author

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 kabadisha marked this pull request as ready for review March 19, 2023 20:31
@StefaBa
Copy link

StefaBa commented Mar 19, 2023

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)

@kabadisha
Copy link
Author

Can you share what 3.conf looks like?

@StefaBa
Copy link

StefaBa commented Mar 19, 2023

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)

@kabadisha
Copy link
Author

kabadisha commented Mar 19, 2023

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 kabadisha marked this pull request as draft August 21, 2023 22:17
Copy link

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

@github-actions github-actions bot added the stale label Apr 16, 2024
@nginxproxymanagerci
Copy link

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

@github-actions github-actions bot removed the stale label Nov 12, 2024
Copy link

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

@github-actions github-actions bot added the stale label Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants