If you loadbalance 2 or more nginx containers you will need to use dockers magic dns under 127.0.0.11
Here is a sample site conf of nginx which proxies every request to a container "nginx" via proxy_pass
on your loadbalancing container edit /etc/nginx/sites-available/<your site>
server
{
listen 80;
resolver 127.0.0.11;
set $upstream http://nginx;
location /
{
proxy_pass $upstream;
}
}
the variable $upstream causes, that the proxy "pings" the nameserver to respond the first answering webfrontend and routes the request to that server
Here is the complete docker-compose.yml
Download the git repo here:
https://github.com/pboethig/loadbalancing
Keine Kommentare:
Kommentar veröffentlichen