Simple tutorial that show how to deploy services in a practical way using docker
, nginx
and letsencrypt
.
- Replace example.org with your domain name and the server ip/port
# data/nginx/app.conf
upstream whoami {
server 10.0.0.10:8000;
}
server_name example.org;
ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
# init-letsencryptinit-letsencrypt
domains=(example.org)
- Create a dummy certificate
chmod +x init-letsencrypt.sh
sudo ./init-letsencrypt.sh
- Automatic Certificate Renewal
To activate auto renew uncoment the following lines on
docker-compose.yml
file:
Nginx service
# command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
Certbot service
# entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
- Everything is in place now. The initial certificates have been obtained and our containers are ready to launch. Simply run docker-compose up and enjoy your HTTPS-secured website or app.
docker-compose up