Last active
October 18, 2018 02:09
-
-
Save yamamoto-febc/2c1c7e575a40b39e28a1c5b133a26d0d to your computer and use it in GitHub Desktop.
usacloudとlego(Let's encrypt)でウェブアクセラレータの証明書更新を自動化 ref: https://qiita.com/yamamoto-febc/items/3d1ac131717603761f9a
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
usacloud dns create --name example.com |
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
$ usacloud dns ls #以下の"NameServers"にDNSサーバの情報が表示される | |
+--------------+--------------+-------------------------------------------------+ | |
| ID | Name | NameServers | | |
+--------------+--------------+-------------------------------------------------+ | |
| 123456789012 | example.com | ns1.gslb4.sakura.ne.jp / ns2.gslb4.sakura.ne.jp | | |
+--------------+--------------+-------------------------------------------------+ |
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
DOMAIN="www.example.com" # ドメイン名 | |
EMAIL="[email protected]" # メールアドレス | |
CERTS_PATH="/home/ubuntu/lego" # legoのデータ(証明書や秘密鍵)格納先 | |
# さくらのクラウドAPIキーを環境変数に設定しておく | |
export SAKURACLOUD_ACCESS_TOKEN=<your-token> | |
export SAKURACLOUD_ACCESS_TOKEN_SECRET=<your-secret> | |
# legoで証明書発行 | |
lego --email="${EMAIL}" --domains="${DOMAIN}" --dns="sakuracloud" --path ${CERTS_PATH} run |
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="www.example.com" # ドメイン名 | |
EMAIL="[email protected]" # メールアドレス | |
CERTS_PATH="/home/ubuntu/lego" # legoのデータ(証明書や秘密鍵)格納先 | |
SITE_NAME="www.example.com" # ウェブアクセラレータに登録したサイト名 | |
# さくらのクラウドAPIキーを環境変数に設定しておく | |
export SAKURACLOUD_ACCESS_TOKEN=<your-token> | |
export SAKURACLOUD_ACCESS_TOKEN_SECRET=<your-secret> | |
# legoで証明書更新 | |
lego --email="${EMAIL}" --domains="${DOMAIN}" --dns="sakuracloud" --path ${CERTS_PATH} renew | |
# usacloudでウェブアクセラレータの証明書更新 | |
usacloud web-accel cert-update -y --cert ${CERTS_PATH}/certificates/${DOMAIN}.crt --key ${CERTS_PATH}/certificates/${DOMAIN}.key ${SITE_NAME} |
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
usacloud simple-monitor create --protocol ssl-certificate --target www.example.com --remaining-days 30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment