From f89d0c06209a1e85fd355bc2ee9518f222377cab Mon Sep 17 00:00:00 2001 From: Rich Lafferty Date: Sun, 30 Aug 2020 12:45:04 -0400 Subject: [PATCH] Supply max_fails=0 on all server entries If nginx-proxy is run on a host whose docker config has multiple networks, then it will generate an additional server XXX down; entry in each upstream for networks on which the container _isn't_. Having more than one server entry in an upstream invokes nginx's max_fails/fail_timeout behavior, which will mark the only live upstream server as down for 10s if it returns ONE error response. Instead, we want nginx to keep retrying the live upstream server regardless of what it returns, since there's nothing else to try. Passing "max_fails=0" on each live server entry disables the max_fails/fail_timeout behavior. --- nginx.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nginx.tmpl b/nginx.tmpl index 66f346c..eb2e8ee 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -9,16 +9,16 @@ {{/* If we got the containers from swarm and this container's port is published to host, use host IP:PORT */}} {{ if and .Container.Node.ID .Address.HostPort }} # {{ .Container.Node.Name }}/{{ .Container.Name }} - server {{ .Container.Node.Address.IP }}:{{ .Address.HostPort }}; + server {{ .Container.Node.Address.IP }}:{{ .Address.HostPort }} max_fails=0; {{/* If there is no swarm node or the port is not published on host, use container's IP:PORT */}} {{ else if .Network }} # {{ .Container.Name }} - server {{ .Network.IP }}:{{ .Address.Port }}; + server {{ .Network.IP }}:{{ .Address.Port }} max_fails=0; {{ end }} {{ else if .Network }} # {{ .Container.Name }} {{ if .Network.IP }} - server {{ .Network.IP }}:{{ .VirtualPort }}; + server {{ .Network.IP }}:{{ .VirtualPort }} max_fails=0; {{ else }} # /!\ No IP for this network! {{ end }}