- Make sure you have docker already installed.
- Install the Nginx proxy with
docker-gen
sudo docker run --name=Nginx -d \ --restart=always \ -p 80:80 -p 443:443 \ -v /data/certs:/etc/nginx/certs:ro \ -v /var/run/docker.sock:/tmp/docker.sock:ro \ -v /data/Nginx/vhost.d:/etc/nginx/vhost.d \ -v /data/Nginx/html:/usr/share/nginx/html \ --label com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy \ jwilder/nginx-proxy
- Since I run portainer, start it up with the
VIRTUAL_HOST
andVIRTUAL_PORT
environment variables so that docker-gen can pick it up. You can do this with any app you desire.
sudo docker run --name Portainer -d \ --restart=always \ -p 9000:9000 \ -v /var/run/docker.sock:/var/run/docker.sock \ -v portainer_data:/data \ -e VIRTUAL_HOST=portainer.local.network \ -e VIRTUAL_PORT=9000 \ portainer/portainer
- Now to use the Let's encrypt container to make certificates for our docker containers:
sudo docker run --name=Letsencrypt -d \ --restart=always \ -v /data/certs:/etc/nginx/certs:rw \ -v /var/run/docker.sock:/var/run/docker.sock:ro \ --volumes-from Nginx \ jrcs/letsencrypt-nginx-proxy-companion
- To enable SSL for your site, set the environment variables
VIRTUAL_PROTO=https
,VIRTUAL_PORT=433
environment as well as theLETSENCRYPT_HOST
andLETSENCRYPT_EMAIL
variables so that docker-gen can pick it up. You can do this with any app you desire. You will also need to mount the certificates and keys within the SSL folder of the container for the container to use the LetsEncrypt keys.
This blog is a knowledge dump of all the technical information floating around in my head. It deals with anything involving software, hardware, gadgets, and technology.
Mar 2, 2018
Automatically make web apps use HTTPS with Let's Encrypt, Nginx, and Docker
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Thanks for contributing!! Try to keep on topic and please avoid flame wars!!