maxeth / nginx-docker-ssl

Easy way of setting up an SSL certificate with letsencrypt for an NGINX Server that runs inside a Docker container.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CertBot SSL with Nginx inside Docker

An Nginx Dockerfile and docker-compose setup that includes the python-certbot-nginx script which helps generating instant SSL certificates for the Nginx proxy.

Setup

  • docker-compose.yml file that composes the Nginx reverse proxy and all other custom Docker images
  • ./nginx directory that contains the Dockerfile of Nginx with a built-in CertBot installation
  • ./letsencrypt directory which acts as a volume for the Nginx image inside docker-compose to maintain the certificate throughout redeployments

Usage

Make sure to include an nginx-volume for letsencrypt as shown in the docker-compose file to maintain the ssl-certificate after a redeployment, otherwise you may get rate-limited for a week for too many re-tries.

  1. Add all your domains (including subdomains) that should have HTTPS to the default-conf file.

  2. docker-compose up -d

  3. Run docker-compose ps to get the name of the running Nginx container & copy it

  4. Execute the Nginx docker container using bash: docker exec -it [name_of_nginx_container] bash

  5. Run the python-certbot-nginx script including all domain names (including subdomains) that should have HTTPS: certbot --nginx -d [domain1] -d [domain2]... And follow the given instructions.

  6. Press Ctrl + d to exit bash

  7. Check if your SSL certificate works here and vist https://[your_domain]


Optional Usage

The Nginx Docker image can also be pulled and integrated to docker-compose directly from Dockerhub under the image name: max37/nginx-ssl:latest. Note that this image exposes the ports 443 and 80 automatically as part of the Dockerfile setup.

About

Easy way of setting up an SSL certificate with letsencrypt for an NGINX Server that runs inside a Docker container.


Languages

Language:Dockerfile 100.0%