Skip to content

Instantly share code, notes, and snippets.

@yamamoto-febc
Last active October 18, 2018 02:09
Show Gist options
  • Save yamamoto-febc/2c1c7e575a40b39e28a1c5b133a26d0d to your computer and use it in GitHub Desktop.
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
usacloud dns create --name example.com
$ usacloud dns ls #以下の"NameServers"にDNSサーバの情報が表示される
+--------------+--------------+-------------------------------------------------+
| ID | Name | NameServers |
+--------------+--------------+-------------------------------------------------+
| 123456789012 | example.com | ns1.gslb4.sakura.ne.jp / ns2.gslb4.sakura.ne.jp |
+--------------+--------------+-------------------------------------------------+
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
#!/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}
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