0

I have a problem with nginx configuration in docker swarm environment. I would like to set the nginx service used as a reverse proxy to make the dockerized services communicate, everything works correctly but I have a problem that occurs in case a service fails to start.

If one of the services is unable to start, the nginx service consequently fails to start as it is unable to detect the upstream associated with the service. nginx logs:

Starting nginx ...

reverse-proxy-stack_nginx-reverse-proxy.1.lae48wy4me1d@ip-172-31-23-236 | nginx: [emerg] host not found in upstream "uptime-kuma" in /data/nginx/proxy_host/5.conf:54

Since many services are hosted inside the swarm, and nginx allows them to communicate with the outside, I would like to avoid that if a service fails to start nginx also remains blocked, and I would therefore like it to still be able to work correctly for the other services.

I'm serving nginx via the image jc21/nginx-proxy-manager:2.10.4 which also offers a GUI to set options for different hosts. I would like to know if there is an option that allows me to still run nginx even if one of these upstreams is not found

1 Answer 1

1

When nginx start up it scans its config one time and resolves any static dns entries for servers using the system configured dns. If entries fail, nginx abandons them.

However, you can configure dynamic dns entries by making them variables. This causes nginx to resolve them at query time, using its configured resolver settings.

This means you need to configure a resolver (127.0.0.11 for docker, or kube-dns.kube-system.svc.cluster.local for K8s), and configure any upstream servers by assigning the hostname to a variable and using the variable rather than hostname directly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.