Boilerplate code for setting up Nginx + Certbot (LetsEncrypt) with auto-renewal using docker-compose. This is really for testing, playing and understanding (I hope).
I found many repos and tutorials online for setting up LetsEncrypt SSL certificates for Nginx containers, but found them hard to follow and many wrapped important bits in automated scripts.
dependency | commands |
---|---|
docker | commands for Debian / Ubuntu |
docker-compose | commands for Debian / Ubuntu |
Clone and enter the repo:
git clone https://github.com/dancasey-ie/nginx-certbot-docker
cd nginx-certbot-docker
Set your domain and email variables for generating your LetsEncrypt certificate
export DOMAIN=<your_hosted_domain>
export EMAIL=<your_email>
Configure your DNS to direct both "<your_hosted_domain>" and "www.<your_hosted_domain>" to your server.
If you just want to run using non-secured http:
docker-compose -f compose-http.yml up # make up_http
If you want to run using https you first must run without https and ask Certbot for a certifcate:
docker-compose -f compose-init-ssl.yml up # make init_ssl
Exit with CTRL+C. Then run:
docker-compose -f compose-https.yml up # make up