-
-
Save hiorws/d7503e04330f2e65250e8649f0972dfd to your computer and use it in GitHub Desktop.
Using jwilder/nginx-proxy with multiple compose files
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: '3' | |
services: | |
nginx-proxy: | |
image: nginx:alpine | |
container_name: proxy-nginx | |
environment: | |
- DEFAULT_HOST=hello.local | |
ports: | |
- 80:80 | |
- 443:443 | |
volumes: | |
- conf:/etc/nginx/conf.d:ro | |
- vhost:/etc/nginx/vhost.d:ro | |
- html:/usr/share/nginx/html:ro | |
- certs:/etc/nginx/certs:ro | |
dockergen: | |
image: jwilder/docker-gen | |
container_name: proxy-dockergen | |
command: -notify-sighup proxy-nginx -wait 5s:30s -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf | |
volumes: | |
- /var/run/docker.sock:/tmp/docker.sock:ro | |
- ./templates:/etc/docker-gen/templates:rw # curl -o templates/nginx.tmpl https://raw.githubusercontent.com/jwilder/nginx-proxy/master/nginx.tmpl | |
- conf:/etc/nginx/conf.d | |
- vhost:/etc/nginx/vhost.d:ro | |
- html:/usr/share/nginx/html | |
- certs:/etc/nginx/certs:ro | |
environment: | |
- DEFAULT_HOST=hello.local | |
letsencrypt: | |
image: jrcs/letsencrypt-nginx-proxy-companion | |
container_name: proxy-letsencrypt | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock:ro | |
- ./templates:/etc/docker-gen/templates:ro | |
- conf:/etc/nginx/conf.d | |
- vhost:/etc/nginx/vhost.d | |
- html:/usr/share/nginx/html | |
- certs:/etc/nginx/certs | |
environment: | |
- DEFAULT_EMAIL=letencrypt@your.personal.tld | |
- NGINX_PROXY_CONTAINER=proxy-nginx | |
- NGINX_DOCKER_GEN_CONTAINER=proxy-dockergen | |
hello: | |
image: nginx:alpine | |
environment: | |
- VIRTUAL_HOST=hello.local | |
volumes: | |
- ./index.html:/usr/share/nginx/html/index.html | |
networks: | |
default: | |
external: | |
name: nginx-proxy | |
volumes: | |
conf: | |
certs: | |
vhost: | |
html: |
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: '3' | |
services: | |
thing: | |
image: jwilder/whoami | |
environment: | |
- VIRTUAL_PORT=8000 | |
- VIRTUAL_HOST=whoami.local | |
# in order for the proxy to see this service, it needs to be on the same network | |
networks: | |
default: | |
external: | |
name: nginx-proxy |
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: '3' | |
networks: | |
default: | |
external: | |
name: nginx-proxy | |
services: | |
nginx-proxy: | |
image: jwilder/nginx-proxy | |
environment: | |
- DEFAULT_HOST=hello.local | |
ports: | |
- 80:80 | |
volumes: | |
- /var/run/docker.sock:/tmp/docker.sock:ro | |
hello: | |
image: nginx:alpine | |
environment: | |
- VIRTUAL_HOST=hello.local | |
volumes: | |
- ./index.html:/usr/share/nginx/html/index.html |
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
$ curl -H "Host: whoami.local" localhost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment