Last active
October 22, 2023 19:43
-
-
Save ohmydevops/80444514405c94fff8e0a7abe25bdaad to your computer and use it in GitHub Desktop.
jwilder/nginx-proxy with VIRTUAL_HOST and custom locations for routing to different versions of smae container
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
### I got the idea from here: | |
### https://stackoverflow.com/questions/39514293/docker-nginx-proxy-how-to-route-traffic-to-different-container-using-path-and-n | |
version: '3.8' | |
services: | |
nginx-proxy: | |
image: jwilder/nginx-proxy:alpine | |
ports: | |
- "80:80" | |
volumes: | |
- /var/run/docker.sock:/tmp/docker.sock:ro | |
- ./vhost.d:/etc/nginx/vhost.d:ro | |
app-latest: | |
image: jwilder/whoami | |
environment: | |
- VIRTUAL_HOST=whoami.local | |
app-v1: | |
image: jwilder/whoami | |
app-v2: | |
image: jwilder/whoami | |
website-latest: | |
image: jwilder/whoami | |
environment: | |
- VIRTUAL_HOST=website.local | |
website-v1: | |
image: jwilder/whoami | |
website-v2: | |
image: jwilder/whoami |
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
### put this file in the vhost.d directory | |
location /website/v1 { | |
proxy_pass http://website-v1:8000; | |
} | |
location /website/v2 { | |
proxy_pass http://website-v2:8000; | |
} |
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
### put this file in the vhost.d directory | |
location /app/v1 { | |
proxy_pass http://app-v1:8000; | |
} | |
location /app/v2 { | |
proxy_pass http://app-v2:8000; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment