0

Nginx fails to start if one of the "proxy_pass" sites is not up or not resolving anymore, therefore bringing dow ALL of the other sites. How can I make it not care if one of the sites is down.

nginx.conf looks like this:

    include /etc/nginx/modules-enabled/*.conf;
stream {
        server {
        listen 80;
        proxy_pass insertwebsitehere.com
        }
      }
events{}
mismar
  • 1
  • Does this answer your question? [Setup nginx not to crash if host in upstream is not found](https://stackoverflow.com/questions/32845674/setup-nginx-not-to-crash-if-host-in-upstream-is-not-found) – araisch Aug 31 '21 at 09:21

1 Answers1

0

You can use a resolver in your conf:

...
server {
        resolver           8.8.8.8;
        listen             80;
        proxy_pass         http://insertwebsitehere.com/;
...
Amin
  • 2,605
  • 2
  • 7
  • 15
  • what if my domain is internal and not resolvable by 8.8.8.8 ? – mismar Sep 01 '21 at 03:15
  • Then use your internal DNS instead of 8.8.8.8 @mismar – Amin Sep 01 '21 at 04:12
  • Thank you Amin, that worked. It now resolves. However if there is no record that matches the proxy_pass entry, then in fails to start. I might be asking a wrong question here, but is there a way to make nginx not care if there is a record or not and just skip that particular server entry? – mismar Sep 01 '21 at 17:00
  • Yes i think if you set resolver under a location, would ignore that proxy if went down. I suggest to open new question and get answer there @mismar – Amin Sep 02 '21 at 08:19
  • And if this answer worked for you, accept that to helping find answer for the others @mismar – Amin Sep 02 '21 at 08:20