Answers: <p>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.</p>
  <p>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.</p>
  <p>This means you need to configure a resolver (<code>127.0.0.11</code> for docker, or <code>kube-dns.kube-system.svc.cluster.local</code> for K8s), and configure any upstream servers by assigning the hostname to a variable and using the variable rather than hostname directly.</p>
  
Answers: CC BY-SA 4.0
Answers: 2024-03-26T09:07:52.087Z
Answers: 2024-03-26T09:07:52.087Z
Answers: Chris Becke
Body: <p>I have a problem with nginx configuration in docker swarm environment. I would like to set the <strong>nginx</strong> service used as a <strong>reverse proxy</strong> to make the dockerized services communicate, everything works correctly but I have a problem that occurs in case a service fails to start.</p>
  <p>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:</p>
  <blockquote>
  <p>Starting nginx ...</p>
  <p>reverse-proxy-stack_nginx-reverse-proxy.1.lae48wy4me1d@ip-172-31-23-236
  | nginx: [emerg] host not found in upstream &quot;uptime-kuma&quot; in
  /data/nginx/proxy_host/5.conf:54</p>
  </blockquote>
  <p>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.</p>
  <p>I'm serving nginx via the image <strong>jc21/nginx-proxy-manager:2.10.4</strong> 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</p>
  
Tags: <docker><networking><nginx><docker-swarm>
Title: Ignore 'host not found in upstream' in docker swarm environment
UserDisplayName: Matteo Pasini
ThreadText: # Ignore 'host not found in upstream' in docker swarm environment
  
  (Asked by: username_0 on 2024-03-15)
  
  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
  
  **Tags:** docker, networking, nginx, docker-swarm
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-03-26. Score: 1 | Accepted answer
  
  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.
  
  
  ---
  
  