Connect Nginx Docker Container to 16 Workers

I have a Nginx Docker container and 16 load-balanced servers, each of which hosts a port on the host machine 8081-8096:

docker run -d \
    --restart always \
    --name "web.${name}" \
    -v /srv/web/web-bundle:/bundle \
    -p "${port}":80 \
    kadirahq/meteord:base

The My Nginx container previously linked to a single image webbefore I tried to scale:

docker run -d \
    --name nginx \
    --link web.1:web.1 \
    -v /srv/nginx:/etc/nginx \
    -v /srv/nginx/html:/usr/share/nginx/html \
    -p 80:80 \
    -p 443:443 \
    nginx

Nginx upstream config:

upstream web {
        ip_hash;
        server 127.0.0.1:8081;
        server 127.0.0.1:8082;
        server 127.0.0.1:8083;
        # ... you get the point
}

I need this Nginx image to be able to hit 127.0.0.1:8081-8096, however it doesn't seem to allow this. I do not want to do 16 --links! It seems to be off.

What is the right way to do this?

+4
source share
1 answer

You have no choice with nginx to reserve requests over a number of ports without specifying each of them.

: https://github.com/jwilder/nginx-proxy

nginx, , . env var , , .

--network --link. , . --link .

docker network create mynet
docker run --network mynet ........
+2

Source: https://habr.com/ru/post/1680575/


All Articles