Skip to content

Instantly share code, notes, and snippets.

@geerteltink
Last active September 6, 2017 07:53
Show Gist options
  • Save geerteltink/0bf3a74089969b93fcb59861cdef0750 to your computer and use it in GitHub Desktop.
Save geerteltink/0bf3a74089969b93fcb59861cdef0750 to your computer and use it in GitHub Desktop.
Let’s Encrypt cronjob script
#!/bin/bash
#
SERVER="https://acme-v01.api.letsencrypt.org/directory"
EMAIL="[email protected]"
DOMAINS=("example.com" "example2.com" "example3.com")
WEBROOT=/tmp/letsencrypt/www
for DOMAIN in "${DOMAINS[@]}"
do
mkdir -p $WEBROOT
letsencrypt certonly \
--authenticator webroot --webroot-path $WEBROOT \
-d $DOMAIN -d www.$DOMAIN \
--server $SERVER --email $EMAIL \
--agree-tos --renew-by-default
done
systemctl restart nginx
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
location /.well-known/acme-challenge {
root /tmp/letsencrypt/www;
}
location / {
return 301 https://example.com$request_uri;
}
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment