Last active
December 28, 2022 11:33
-
-
Save mfts/e59c0e2e4e02b5626d487a741410fc42 to your computer and use it in GitHub Desktop.
Automate Lets Encrypt certificate generation for Heroku via Server
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
apt update | |
# install acme.sh | |
curl https://get.acme.sh | sh | |
# install heroku-cli | |
apt install snapd | |
sudo snap install --classic heroku | |
heroku login --interactive | |
# for cloudflare dns (will be stored in .acme.sh/account.conf) | |
export CF_Email=$CLOUDFLARE_EMAIL | |
export CF_Key=$CLOUDFLARE_API_KEY | |
# you own $DOMAIN and issue a certificate and update it upon renewal to your heroku app | |
acme.sh --issue -d $DOMAIN --dns dns_cf --renew-hook "~/heroku-script.sh $DOMAIN $HEROKU_APP" | |
# you own $MY_ALIAS_DOMAIN but offer your user a $CUSTOM_DOMAIN | |
acme.sh --issue -d $CUSTOM_DOMAIN --domain-alias $MY_ALIAS_DOMAIN --dns dns_cf --renew-hook "~/heroku-script.sh $CUSTOM_DOMAIN $HEROKU_APP" | |
# a cronjob will be created and renew each domain you will subsequently create. | |
# however, we still need to push the certificates to heroku once | |
heroku certs:add /root/.acme.sh/$DOMAIN/fullchain.cer /root/.acme.sh/$DOMAIN/$DOMAIN.key --app $HEROKU_APP |
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/bash | |
DOMAIN="$1" | |
HEROKU_APP="$2" | |
heroku certs:update "/root/.acme.sh/$DOMAIN/fullchain.cer" "/root/.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