Skip to content

Instantly share code, notes, and snippets.

@jordancrawfordnz
Created July 19, 2021 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordancrawfordnz/822943aa00d7a46c2c2d3fa85ba6d83b to your computer and use it in GitHub Desktop.
Save jordancrawfordnz/822943aa00d7a46c2c2d3fa85ba6d83b to your computer and use it in GitHub Desktop.
Docker Compose example for auto renewing certs
# I use this as my most recent solution to the problems described in:
# https://jordancrawford.kiwi/home-server-without-portforward
# This is an excerpt.
# To access LetsEncrypt Manager commands, use docker-compose run --rm letsencrypt <command>.
# To setup DHParams, use: https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html openssl dhparam -out dhparam.pem 4096
version: '2'
services:
nginx:
container_name: nginx
image: nginx
ports:
- 80:80
- 443:443
restart: always
volumes:
- ~/services/letsencrypt/data:/ssl
- ~/services/letsencrypt/www:/acme-challenge
- ./nginx-proxy:/etc/nginx/conf.d
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
certbot:
container_name: certbot
image: certbot/certbot
volumes:
- ~/services/letsencrypt/data:/etc/letsencrypt
- ~/services/letsencrypt/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
restart: always
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment