Created
October 5, 2018 06:40
-
-
Save hsinewu/442e8af04b2a4303d217c36d81867078 to your computer and use it in GitHub Desktop.
Nginx load balance with docker
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: | |
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 | |
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
upstream foo { | |
server web1; | |
server web2; | |
} | |
server { | |
listen 80 default; | |
location / { | |
proxy_pass http://foo; | |
} | |
} |
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
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