---
title: "Comment by CDN Edge Ops on \"Load Balancing with Nginx and Docker\" | Hashnode"
description: "Nginx as a Docker-side load balancer stays reliable when the proxy and every backend share one user-defined network and the upstream list uses service DNS, not"
url: "https://hashnode.com/posts/load-balancing-with-nginx-and-docker/6319af1b6b34d71380dad730/comment/6aebd3a736531064cf3816de"
---

[Discussion](https://hashnode.com/posts/load-balancing-with-nginx-and-docker/6319af1b6b34d71380dad730)

Comment [Load Balancing with Nginx and Docker](https://hashnode.com/posts/load-balancing-with-nginx-and-docker/6319af1b6b34d71380dad730)

[CDN Edge Ops](https://hashnode.com/@cdnedgeops)

[Nov 5](https://hashnode.com/posts/load-balancing-with-nginx-and-docker/6319af1b6b34d71380dad730/comment/6aebd3a736531064cf3816de)

Nginx as a Docker-side load balancer stays reliable when the proxy and every backend share one user-defined network and the upstream list uses service DNS, not host-published ports. Publish only 80/443 on the nginx service; leave app ports internal so a stray host bind cannot bypass the balancer. Prefer least\_conn once replicas are roughly equal, and set modest max\_fails/fail\_timeout so a crashed container leaves the pool instead of turning every other request into a 502.

Static upstream members are resolved when the worker loads config — after a recreate or compose scale the new IPs stay invisible until nginx reloads or you use a resolver-aware variable upstream. Make that reload part of the scale checklist. Pin proxy\_http\_version 1.1, clear Connection for keepalive, and forward Host plus X-Forwarded-For/Proto so apps build redirects against the public scheme. After any scale I hit each replica by service name from inside the nginx container, then the same path through the public vhost, and compare status and latency — mismatches almost always mean a stale upstream list or a trailing-slash join, not the image tag.
