Skip to content

Instantly share code, notes, and snippets.

@hsinewu
Created October 5, 2018 06:40
Show Gist options
  • Save hsinewu/442e8af04b2a4303d217c36d81867078 to your computer and use it in GitHub Desktop.
Save hsinewu/442e8af04b2a4303d217c36d81867078 to your computer and use it in GitHub Desktop.
Nginx load balance with docker
version: "2"
services:
gate:
image: nginx:latest
ports:
- 80:80
volumes:
- ./load-balance.conf:/etc/nginx/conf.d/default.conf
web1:
image: nginx:latest
volumes:
- ./serve.conf:/etc/nginx/conf.d/default.conf
web2:
image: nginx:latest
volumes:
- ./serve.conf:/etc/nginx/conf.d/default.conf
upstream foo {
server web1;
server web2;
}
server {
listen 80 default;
location / {
proxy_pass http://foo;
}
}
server {
listen 80;
location / {
add_header content-type text/html;
return 200 'server_addr is $server_addr';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment