Created
June 3, 2020 08:58
-
-
Save mfts/0b4f8d2ec5fb7adba172c33d5eebc111 to your computer and use it in GitHub Desktop.
Let's Encrypt for Wildcard Domains with Heroku and Cloudflare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
# NEEDS THE FOLLOWING VARS IN ENV: | |
# DOMAIN | |
# CLOUDFLARE_EMAIL | |
# CLOUDFLARE_API_KEY | |
# HEROKU_APP | |
# Download dependencies | |
git clone https://github.com/Neilpang/acme.sh.git | |
cd ./acme.sh | |
# Force ensures it doesnt fail because of lack of cron | |
./acme.sh --install --force | |
# Map to environment variables that the ACME script requires | |
export CF_Email=$CLOUDFLARE_EMAIL | |
export CF_Key=$CLOUDFLARE_API_KEY | |
# Generate wildcard certificate (this will take approx 130s) | |
~/.acme.sh/acme.sh --issue -d $DOMAIN -d "*.$DOMAIN" --dns dns_cf | |
# Update the certificate in the live app | |
heroku certs:update "~/.acme.sh/$DOMAIN/fullchain.cer" "~/.acme.sh/$DOMAIN/$DOMAIN.key" --confirm $HEROKU_APP --app $HEROKU_APP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment