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

setup nginx not to crash if host in proxy pass not found

Open pecqueurS opened this issue 3 years ago • 12 comments

Is your feature request related to a problem? Please describe. When the proxy_host is used to proxy a docker container and this container is shut down afterwards, if you restart nginx-proxy-manager, it generates an error because the domain no longer exists. Nginx-proxy-manager can no longer launch.

Describe the solution you'd like Modify the proxy pass option in nginx actual : proxy_pass http://:/; proposal :

No stop when error on config

https://stackoverflow.com/questions/32845674/setup-nginx-not-to-crash-if-host-in-upstream-is-not-found/32846603#32846603

https://stackoverflow.com/questions/35744650/docker-network-nginx-resolver/37656784#37656784

resolver 127.0.0.11 valid=30s ipv6=off; set $upstream_pass http://:/; proxy_pass $upstream_pass;

Describe alternatives you've considered Easier access to proxy_host configuration when nginx-proxy-manager is off to remove non-working configuration

Additional context error when nginx-proxy-manager is restarted : host not found in upstream "bar:3000" in /data/nginx/proxy_host/1.conf

pecqueurS avatar Jan 26 '22 01:01 pecqueurS

I also had this problem. I've raised a PR which I believe fixes the issue: https://github.com/NginxProxyManager/nginx-proxy-manager/pull/2672 If you can test my fix, that would be really helpful.

kabadisha avatar Mar 19 '23 19:03 kabadisha

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

github-actions[bot] avatar Feb 25 '24 01:02 github-actions[bot]

Same problem here, it doesn't make sense to fail the Nginx server for one proxy pass, since you can use it as an proxy for multiples addresses. So if some of websites fails, all the others will too.

Scemist avatar May 03 '24 18:05 Scemist

location /foo/ {
        resolver 127.0.0.11; #(in my case with docker)
        set $upstream_server someserver:80;
        proxy_pass http://$upstream_server/;
}

now nginx don't crashes when someserver:80 is down

Upd: but then nginx cut off the rest of the request uri. http://host/foo/bar becomes just http://someserver:80/. How to fix this?

Lavshyak avatar Jun 08 '24 20:06 Lavshyak

location /foo/ {
        resolver 127.0.0.11; #(in my case with docker)
        set $upstream_server someserver:80;
        proxy_pass http://$upstream_server/;
}

now nginx don't crashes when someserver:80 is down

Upd: but then nginx cut off the rest of the request uri. http://host/foo/bar becomes just http://someserver:80/. How to fix this?

Hi. Look at this article:

https://dev.to/danielkun/nginx-everything-about-proxypass-2ona#let-nginx-start-even-when-not-all-upstream-hosts-are-available

tyyrok avatar Jul 15 '24 19:07 tyyrok

nginx:mainline-alpine3.18-perl works well for me. I don't notice any failures

Lavshyak avatar Aug 07 '24 14:08 Lavshyak

Also having the same issue here. Quite frustrating to get working.

ZandercraftGames avatar Jan 07 '25 16:01 ZandercraftGames

got the same with latest nginx docker image

abstract-entity avatar Mar 10 '25 17:03 abstract-entity

In the same annoying situation, like I build a container for Docker and Podman. Depending on the network subnet and the container engine, I can't guess the resolver IP. I'm just blocked because there is no options. Should be good to define the resolver directive with a default value (for example "host") that preserve the default behavior (auto resolve with /etc/resolv.conf) and also activate the other wanted behavior that is the main subject of this issue.

I will just switch from NGINX to anything else more flexible, like who likes to have nothing working because of a little bit of dust in some config file ?

Legendary4226 avatar Aug 14 '25 15:08 Legendary4226

Man.. this is a super annoying and totally unnecessary “feature”. If the backend is dead just let it be dead, and use that http 500 code to tell us.

What is the difference between not starting nginx because the backend is dead and killing it if the backend dies 1 second after nginx goes up?

You would not kill the proxy if the pleb backend is acting up, and nobody does it. But you don’t allow it to start because of the same issue. There is simply no practical and technical reason to not allow the process to start because of this.

We run nginx with over 50 custom locations across multiple services. And it simply won’t start if one is dead or missconfigured (like typing the wrong port there).

yn-alex avatar Aug 29 '25 21:08 yn-alex

Any info on that? I'm also curious as to why this happens and honestly seems like a bug to me. We've got multiple independent containerized services running and removing one without disabling the proxy pass in NPM renders NPM inoperable, in practice taking down our whole suite of services..

Daredevll avatar Oct 27 '25 15:10 Daredevll

Stupid feature, sometimes one small host could be down, and whole server if rebooted, nginx-proxy-manager wont start, of course of nginx host check feature, maybe we could do something smart ? if nginx failing to start, we could start at least itself in safe mode ? so user could disable failty host

tjunussov avatar Nov 19 '25 10:11 tjunussov