Docker Community Forums

Share and learn in the Docker community.

Nginx swarm cluster configuration

swarm
docker

(Tisegware) #1

Hi everyone.

I have a swarm cluster with 1 master and 2 nodes with 4 tomcat applications listen different ports like this:

app1 = 8085
app2= 8086
app3= 8087
app4 = 8088

now i have nginx container inside of the nodes with upstream configuration and proxy_pass for container applications:

upstream app1 {
server 172.30.2.236:8088;
server 172.30.2.66:8088;
}

location /app1/ {
proxy_pass http://app1/app1/;
access_log /var/log/nginx/app1.access.log main;
}

but if i want to add extra nodes, or use AWS auto scalling for create new nodes with performance metrics i don’t know the future node IP’s and my actualy configuration doesn’t work.

someone have idea for this configuration? my structure like this:

AWS ALB -> MASTER IP’s > CONTAINERS

If i use nginx like container in master, how i get node IP’s for update my nginx.conf, for example?

Thanks


(Keajer) #2

you just need to specify service name in upstream

upstream service_name {
    server service_name:port#;
}

(Tisegware) #3

I note one thing… if i specify service_name in nginx configuration, when my service goes down, nginx don’t reload send traffic to container when service goes up, i need to reload nginx service for work.

when i used masterip:port works fine!

i made something wrong?