1

I am using nginx to do TCP forwarding based on hostname as discussed here: Nginx TCP forwarding based on hostname

When the upstream containers are taken down for a short period of time (5 or so mins), and then brought back up, nginx doesn't seem to re-resolve them (continue to get 111: connection refused error).

I've attempted to put a resolver in the server block of the nginx config:

server {
   listen 443;
   resolver x.x.x.x valid=30s
   proxy_pass $name;
   ssl_preread on;
}

I still get the same behaviour with this in place.

thewire247
  • 795
  • 1
  • 9
  • 24
  • This would be handled by Docker's swarm mode since the service VIP lasts for the life of the service while containers in the service can be constantly replaced. – BMitch Mar 22 '18 at 09:16
  • Problem is when the service is taken offline for a periud of time, when we update the service there isn't any problem – thewire247 Mar 22 '18 at 14:45
  • don't delete the service, update it. Or scale down to 0/use a non existent constraint, to disable it. – BMitch Mar 22 '18 at 14:48

1 Answers1

0

Like BMitch says, you can scale to 0 to ensure DNS remains available to Nginx.

But really, if you're using nginx in Swarm, I recommend using a Swarm-aware proxy solution that dynamically updates nginx/haproxy config's based on Services that have the proper labels. In those cases, when the service was removed, the config would also be removed from the proxy. One's I've used include:

Traefik

Docker Flow Proxy

Bret Fisher
  • 8,164
  • 2
  • 31
  • 36