Nginx + certbot の SSL 自動更新で詰まるポイント
最終更新: 2026-04-24 · 所要 6 分
結論
- webroot モードなら --webroot-path と nginx root が一致しているか
- reload が post-hook に設定されているか
- cron vs systemd timer どちらで回しているか
どういう場面で必要か
Ubuntu / Debian / Amazon Linux で Nginx + certbot 運用していて、証明書が更新されない or 反映されない時。
実務で見るポイント
- certbot renew --dry-run --renew-hook 'systemctl reload nginx' で挙動確認
- /etc/letsencrypt/renewal/DOMAIN.conf の webroot_path を確認
- nginx -t && systemctl reload nginx を毎回手動で試す
- /etc/cron.d/certbot または systemctl list-timers | grep certbot
- 成功時の post-hook で systemctl reload nginx が呼ばれているか
よくある失敗
- Nginx の alias / root / location の設定ミスで .well-known/acme-challenge が 404
- 複数サイト運用で webroot が異なるため一部ドメインだけ更新失敗
- certbot install 時の --nginx で自動設定したが、カスタム設定と競合
- reload ではなく restart が必要なケース(モジュールロード時等)
チェックリスト
- [ ] certbot renew --dry-run 成功
- [ ] curl http://<yours>/.well-known/acme-challenge/test が 200 or 404 NotFound
- [ ] post-hook に reload コマンドがある
- [ ] nginx -t で syntax OK
- [ ] journalctl -u certbot.timer で最新実行を確認
よくある質問
--standalone と --webroot どちらが良い?
Nginx を停止したくなければ --webroot が基本。80 番が空いているなら --standalone も使えますが停止が必要。
Nginx が複数設定ファイルにまたがる場合は?
すべての virtual host で acme-challenge の alias が正しく設定されていることを確認。include で共通化推奨。
cron と systemd timer どちらが良い?
Debian/Ubuntu 系なら systemd timer が標準。cron は互換性の面でカスタム環境向き。
Let's Encrypt 以外の CA を使いたい
ZeroSSL や acme.sh + buypass などは certbot の --server オプションで切り替え可能。