跳至内容

给 Nginx 配置 Let's Encrypt 免费证书与自动续期

小站上 HTTPS 的成本几乎为零,记录下 97if.com 的配置过程。

1. 安装 certbot

apt install certbot python3-certbot-nginx

2. 签发证书

certbot --nginx -d 97if.com -d www.97if.com

certbot 会自动改 nginx 配置,加 80→443 跳转。

3. 自动续期

certbot 装好后自带 systemd timer,确认即可:

systemctl list-timers | grep certbot

4. 验证

curl -I https://97if.com

返回 HTTP/2 200 即成功。