SSL 证书配置指南
SSL 证书用于加密网站通信,HTTPS 已成为网站标配。Let's Encrypt 提供免费 SSL 证书。
SSL 证书类型
免费证书
Let's Encrypt 90 天有效期
自动续期
适合个人和小型网站
付费证书
商业 CA 颁发
1-2 年有效期
适合企业网站
Let's Encrypt 证书申请
安装 Certbot
CentOS yum install certbot python3-certbot-nginx

Ubuntu apt install certbot python3-certbot-nginx
申请证书
Nginx certbot --nginx -d 域名
Apache certbot --apache -d 域名
手动 certbot certonly --standalone -d 域名
自动续期
测试续期 certbot renew --dry-run
配置定时任务 crontab -e
添加 0 3 * * * certbot renew --quiet
Nginx 配置 HTTPS
编辑 Nginx 配置文件

配置 listen 443 ssl
设置 ssl_certificate 和 ssl_certificate_key
配置 SSL 协议和加密套件
重启 Nginx
验证配置
浏览器访问 https://域名
查看证书信息
使用 SSL Labs 测试