Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

310
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda