Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

303
Visualizações
docker-swarm + nginx load balancing: Do i need to set upstream in .conf?

i'm fairly new to docker-swarm and nginx, my current setup is a basic flask/gunicorn app using nginx as reverse proxy deployed on a docker-swarm, right now it runs successfully, when i query one of the swarm nodes it returns the host ID of a different host in the swarm each time, which i assume is load balancing happening.

Though i don't know whether that is docker swarm doing it or nginx.

EDIT: I am scaling the services across the hosts in the swarm.

I've seen various examples of setting the upstream variable (which i don't have) and manually adding each host ip in there, my question is whether i need to include that for load balancing to work properly/how can i test if it's balancing properly?

Here is my nginx dockerfile and docker-compose.yml

worker_processes  3;

events { }

http {

  keepalive_timeout  360s;

  server {

      listen 8080;
      server_name app;
      charset utf-8;

      location / {
          proxy_pass http://app:5000;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      }
  }
}
version: '3'

services:

  app:
    image: <repouser>/<repo>:flask
    deploy:  
      replicas: 1
      restart_policy:  
        condition: on-failure    
    networks:
      - apinetwork
    expose:
      - "5000"
    ports:
      - "5000:5000"

  nginx:
    image: <repouser>/<repo>:nginx
    deploy:  
      replicas: 1
      restart_policy:  
        condition: on-failure  
    networks:
      - apinetwork
    expose:
      - "80"
    ports:
      - "80:8080"

networks:
  apinetwork:
    driver: overlay

Thanks for any help.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda