Welcome! Log In Create A New Profile

Advanced

nginx container acting as LB

Posted by esxi1979 
nginx container acting as LB
March 25, 2019 02:25AM
Hello

I have container with below file

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

stream {
upstream cb_80 {
server server-04.domain.com:35373 max_fails=2 fail_timeout=30s;
server server-05.domain.com:35373 max_fails=2 fail_timeout=30s;
server server-06.domain.com:35373 max_fails=2 fail_timeout=30s;
server server-07.domain.com:35373 max_fails=2 fail_timeout=30s;
server server-08.domain.com:35373 max_fails=2 fail_timeout=30s;
server server-09.domain.com:35373 max_fails=2 fail_timeout=30s;
server server-10.domain.com:35373 max_fails=2 fail_timeout=30s;
}
server {
listen 80;
proxy_pass cb_80;
}

}

stream {
upstream cb_443 {
server server-04.domain.com:33688 max_fails=2 fail_timeout=30s;
server server-05.domain.com:33688 max_fails=2 fail_timeout=30s;
server server-06.domain.com:33688 max_fails=2 fail_timeout=30s;
server server-07.domain.com:33688 max_fails=2 fail_timeout=30s;
server server-08.domain.com:33688 max_fails=2 fail_timeout=30s;
server server-09.domain.com:33688 max_fails=2 fail_timeout=30s;
server server-10.domain.com:33688 max_fails=2 fail_timeout=30s;
}

server {
listen 443;
proxy_pass cb_443;
}


}





the host which runs this conatiner will get he :80 & :443 with above

so mysite.domain.com:80 & mysite.domain.com:443 shuould do the lb

problem is

docker run --detach --name mysite --restart=unless-stopped --publish 80:80 --volume ${PWD}/nginx.conf:/etc/nginx/nginx.conf:ro nginx:stable-alpine

i can expose only 1 port

pls suggest
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 91
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready