Skip to content

Instantly share code, notes, and snippets.

@jonathanvanschenck
Created March 2, 2022 22:12
Show Gist options
  • Save jonathanvanschenck/c5004f2d8976bb5e557de04fa4fd2493 to your computer and use it in GitHub Desktop.
Save jonathanvanschenck/c5004f2d8976bb5e557de04fa4fd2493 to your computer and use it in GitHub Desktop.
Certbot webroot with docker
# nginx configuration
server {
listen 80;
location /.well-known/acme-challenge/ {
root /var/www/letsencrypt;
}
...
}
...
docker run -it --rm --name cerbot \
-v "/etc/letsencrypt:/etc/letsencrypt" \
-v "/var/www/letsencrypt:/var/www/letsencrypt" \
# https://eff-certbot.readthedocs.io/en/stable/using.html#webroot
certbot/certbot certonly --webroot -v\
-m [email protected] \
-w /var/www/letsencrypt \
-d your.domain.com
ls /etc/letsencrypt/live
# Then, update nginx with your domian:
# server {
# listen 443 ssl;
# ....
# ssl_certificate /etc/letsencrypt/live/your.domain.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/your.domain.com/key.pem;
# ....
# }
# Don't forget to reload nginx
# service nginx reload
docker run -it --rm --name cerbot \
-v "/etc/letsencrypt:/etc/letsencrypt" \
-v "/var/www/letsencrypt:/var/www/letsencrypt" \
# https://eff-certbot.readthedocs.io/en/stable/using.html#webroot
certbot/certbot renew
# Don't forget to reload nginx
service nginx reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment