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.