Nginx をセットアップした CentOS 7 で Let's Encrypt の SSL を Certbot ACME クライアントで自動取得および自動設定する手順の解説。
リポジトリの導入
yum epel-release
certbot
パッケージは EPEL リポジトリで利用可能。
Certbot と Nginx プラグインのインストール
yum certbot python2-certbot-nginx
2019年2月7日リリースの Certbot 0.31.0 がインストールされる。
epel-testing
リポジトリを利用すると、2019年5月7日リリースの 0.34.2 がインストールされる。
SSL 証明書の取得
certbot \
--nginx \
--agree-tos \
--domain example.jp \
--email 'admin@example.jp' \
--no-eff-email
certbot
コマンドのサブコマンドを省略するとデフォルトの run
になる。
Nginx の設定ファイルまで自動設定する場合は certonly
および --standalone
や --webroot
を指定しない。
--nginx
オプションは Nginx プラグイン (python2-certbot-nginx
パッケージ) がのインストールが必要。
--agree-tos
オプションは ACME サーバーの Subscriber Agreement への同意。
--no-eff-email
オプションは EFF 等にメールアドレスを共有しない。共有する場合は代わりに --eff-email
オプションを指定する。
自動更新の設定
systemctl start certbot-renew.timer
systemctl enable certbot-renew.timer
systemctl list-timers --all
Cron ではなく systemd の Timer を利用して自動更新を設定する。