letsencrypt の certbot renew を apache plugin から nginx(webroot) に切り替える
環境
- Debian 9.3
- certbot 0.10.2
内容
もともと apache がサポートされていたため apache を利用して letsencrypt を利用していたが nginx を使うように変更したため nginx で直接 https 処理を行うように変更したい。
$ vim /etc/letsencrypt/renewal/example.com.conf
下記のようになっているはず
# Options used in the renewal process [renewalparams] authenticator = apache installer = apache account = ......
これを下記のように書き換える
# Options used in the renewal process [renewalparams] authenticator = webroot installer = None account = ...... [[webroot_map]] example.com = /path/to/webroot
このあとそのまま certbot renew をするとよい。 また cron で自動で確認するようになっていると思うので /etc/cron.d/certbot の内容の一部を下記のように書き換える。reload でもいいかもしれないが自分の環境では特に気にすることもないためそのまま restart している。
.... && certbot -q renew ↓ .... && certbot -q renew --post-hook "service nginx restart"
--post-hook か --renew-hook がいいかは1年ぐらい運用したけど毎回失敗しててよくわからなかった。