title: nginx-proxy+docker swarm => load balancer not working
body: <p>I am trying to use nginx-proxy with Docker Swarm mode. I have a stack for nginx-proxy and a stack for a whoami container which is replicated 3 times.</p>
  
  <p>THe problem is that when I query the cluster, I always get response from the same whoami. When I hit <code>docker service scale whoami_whoami=1</code> then nginx replies with <code>503</code> status code which means it keeps asking one of the removed replicas.</p>
  
  <pre class="lang-yaml prettyprint-override"><code># proxy.yml
  version: '3.8'
  
  networks:
    proxy:
      driver: overlay
      name: proxy
  
  services:
    nginx:
      image: jwilder/nginx-proxy:latest
      networks:
        - proxy
      environment:
        - HTTPS_METHOD=noredirect
      volumes:
        - /var/run/docker.sock:/tmp/docker.sock:ro
        # - ${CLU_ROOT}/proxy/certs:/etc/nginx/certs:ro
      ports:
        - 80:80
        # - 443:443
      deploy:
        placement:
          constraints:
            - node.role == manager
  </code></pre>
  
  <pre class="lang-yaml prettyprint-override"><code># whoami.yml
  version: '3.8'
  
  networks:
    proxy:
      external: true
  
  services:
    whoami:
      image: jwilder/whoami:latest
      networks:
        - proxy
      environment:
        - VIRTUAL_HOST=whoami.dev.interne.eseo.fr
      deploy:
        replicas: 3
  </code></pre>
  
  <p>I was thinking that nginx will send requests to "whoami" and that it was the role of Swarm to balance between replicas. Am I wrong ?</p>
  
  <p>On the other hand, when I publish the port <code>8000</code> of the whoami service and hit: <code>while sleep 1; do clear; curl whoami....:8000; done</code> then every replies come from a different replica.</p>
  
  <p>Thanks in advance</p>