Posts

Showing posts from November, 2020

NGINX and HTTPs with Let’s Encrypt, Certbot, and Cron dockerization in production

Docker  is a popular open source containerization platform and it frees your hands to build your applications in development and production. In this post, I'm going to walk you through how to build a production grade HTTPs secured Nginx server with Docker, Docker Compose, Let’s Encrypt(its client certbot). Let’s Encrypt certificates last 90 days and will need to be renewed after the certificate expires. So I will also provide details to script the renewal in crontab in Docker container. 1. Basic Example In development, we need a basic Nginx container without HTTPs to fast setup our local test environment. I use Nginx official docker image and wrap up all the stuff with docker-compose. YAML 1 version : '3.4' 2 3 services : 4 nginx : 5   container_name : nginx 6   image : nginx : stable 7   restart : always 8   volumes : 9     - ./nginx/config/nginx.conf:/etc/nginx/nginx.conf 10     - ./nginx/config/conf.d/local:/etc/nginx/conf.d 11     - /tmp/logs/nginx:/var/