Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hiorws
Forked from w33ble/docker-compose.advanced.yml
Created January 1, 2022 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiorws/d7503e04330f2e65250e8649f0972dfd to your computer and use it in GitHub Desktop.
Save hiorws/d7503e04330f2e65250e8649f0972dfd to your computer and use it in GitHub Desktop.
Using jwilder/nginx-proxy with multiple compose files
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:
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
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
$ curl -H "Host: whoami.local" localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment