Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

311
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!