Nginx Reverse Proxy | Auto HTTPS with Let's Encrypt | Multiple Docker Containers
Combine the power of Nginx Reverse Proxy, Let's Encrypt and Docker for a better web development and production experience
Reverse Proxy
~/proxy/docker-compose.yml
version: "3.7"
services:
reverse-proxy:
image: nginxproxy/nginx-proxy:latest
container_name: reverse-proxy
volumes:
- ./conf.d:/etc/nginx/conf.d
- certs:/etc/nginx/certs
- vhost:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
restart: always
networks:
- net
ports:
- 80:80
- 443:443
letsencrypt:
image: nginxproxy/acme-companion:latest
container_name: letsencrypt-helper
volumes:
- certs:/etc/nginx/certs
- vhost:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
- acme:/etc/acme.sh
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
NGINX_PROXY_CONTAINER: reverse-proxy
DEFAULT_EMAIL: email@certrenewal.com
restart: always
depends_on:
- reverse-proxy
networks:
- net
volumes:
certs:
vhost:
html:
acme:
networks:
net:
external: true
Container
~/appA/docker-compose.yml
version: "3.7"
services:
ghost:
image: ghost:5.75.0
restart: always
container_name: named-container
environment:
database__client: mysql
database__connection__host: mysqlpath
database__connection__port: 3306
database__connection__user: ghostuser
database__connection__password: 'password'
database__connection__database: ghostdb
url: https://yours.domain.com
VIRTUAL_HOST: yours.domain.com
LETSENCRYPT_HOST: yours.domain.com
volumes:
- ./ghost/content:/var/lib/ghost/content
networks:
- net
networks:
net:
external: true