Nginx Proxy Containers
This approach lets you do a few really powerful things:
- Give non-SSL enabled applications SSL capabilities using a proxy
- Automate signing up and renewing LetsEncrypt certificates
- Allow multiple containers to exist on a single host and not worry about configuring a webserver
Use docker-letsencrypt-nginx-proxy with nginx-proxy in a single docker-compose.yml. Here's what it's doing:
- The host ports 80 and 443 go into the nginx-proxy container
- The volumes certs, vhostd, and html are persistent (important for certs!)
- The docker sockets is what the container watches for new additions
- The nginx-proxy private network registers new containers and gives them a certificate if they don't have one (define this information in each container's Dockerfile or docker-compose.yml)
- Nginx specific settings can be added to the vhost.d directory with the virtual host name as the file name
A container can specify a few optional parameters that are understood by the docker-letsencrypt-ngingx-proxy setup:
- VIRTUAL_HOST is the host name that nginx will use for the container
- VIRTUAL_PORT is the port that will be mapped to the host name provided
- LETSENCRYPT_HOST is the name used for the LetsEncrypt certificate
- LETSENCRYPT_EMAIL is the address used for LetsEncrypt e-mail
- "networks" must be specified to ensure that nginx-proxy knows about the container
- "expose" rather than map ports if you want that container to be proxied using the hostname