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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
proxy: | |
image: sameersbn/nginx:1.10.3 | |
hostname: proxy | |
ports: | |
- "8080:80" | |
volumes: | |
- ./nginx/sites-enabled:/etc/nginx/sites-enabled | |
- ./logs/proxy/nginx/:/var/log/nginx | |
networks: | |
- internal | |
front1: | |
image: sameersbn/nginx:1.10.3 | |
hostname: front1 | |
volumes: | |
#- ./nginx_front1/sites-enabled:/etc/nginx/sites-enabled | |
- ./logs/front1/nginx/:/var/log/nginx | |
- ./nginx_front1/www:/usr/share/nginx/html | |
networks: | |
- internal | |
networks: | |
internal: | |
driver: bridge |
Download the git repo here:
https://github.com/pboethig/loadbalancing
Keine Kommentare:
Kommentar veröffentlichen