nginx-certbot-autocert
Simple implementation dockerized Nginx with certbot for auto generate ss certs for IP or trusted certificate for domain name.
For use:
- Add the repositories files to your project (certbot and nginx).
- Add in your docker-compouse.
- Create .env file or add to your .env variables from example.env.
- Run Nginx and Certbot containers, e.g.
docker-compouse up --build nginx certbot
. - Restart Nginx container -
docker restart nginx
.
Done!
If the certificate expires, just restart certbot container - docker restart certbot
How it works:
-
When Nginx container start, run 00-ssl_conf.sh script. The script check existing valid certificates, if it does exist create self-singed cert. Because, Nginx can`t start without any certs.
-
Then start Certbot container, run init.sh script and check for valid trusted certificate. If them does not exist, try test create trusted certificate. If test create success, create trusted certificate.
-
Then need restart Nginx for attach new certificate -
docker restart nginx
.