certbot --version
sudo certbot renew --dry-run
Nếu báo Congratulations là OK.
Let’s Encrypt cài qua apt thường đã có sẵn timer.
Kiểm tra:
systemctl list-timers | grep certbot
Nếu thấy:
certbot.timer
=> Đã tự động chạy 2 lần/ngày.
Kiểm tra trạng thái:
systemctl status certbot.timer
Mở cron:
sudo crontab -e
Thêm dòng:
0 3 * * * certbot renew --quiet && systemctl reload nginx
Giải thích:
| Phần | Ý nghĩa |
|---|---|
| 0 3 * * * | 3h sáng mỗi ngày |
| certbot renew | kiểm tra và gia hạn |
| --quiet | không log rác |
| reload nginx | load lại SSL mới |
Có thể cấu hình hook luôn:
sudo certbot renew --deploy-hook "systemctl reload nginx"
Hoặc tạo file:
sudo nano /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh
Nội dung:
#!/bin/bash systemctl reload nginx
Rồi:
chmod +x /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh
openssl x509 -enddate -noout -in /etc/letsencrypt/live/domain.com/fullchain.pem
Hoặc:
certbot certificates
Let’s Encrypt:
Trường hợp:
→ Có thể không cần Let’s Encrypt ở server.