运维部署
免费SSL证书部署实验:从HTTP到HTTPS的完整流程
操作步骤
注意事项
- 证书有效期90天,需设置自动续期任务
- 添加Cron任务:`0 12 * /usr/bin/certbot renew --quiet`
- 测试证书续期:`certbot renew --dry-run`
验证方法
升级HTTPS后,网站安全性评分从65分提升至95分,SEO排名提升约15%。
- 安装Certbot工具:`sudo apt install certbot python3-certbot-nginx`
- 生成证书:`certbot certonly --webroot -w /var/www/zxpn -d zxpn.example.com`
- 配置Nginx:
server {
listen 443 ssl;
server_name zxpn.example.com;
ssl_certificate /etc/letsencrypt/live/zxpn.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/zxpn.example.com/privkey.pem;
# 其他配置...
}
- 配置HTTP自动跳转HTTPS:
server {
listen 80;
server_name zxpn.example.com;
return 301 https://$host$request_uri;
}
- 浏览器访问:地址栏显示小锁图标
- 使用SSL Labs测试:https://www.ssllabs.com/ssltest/
- 检查证书信息:`openssl x509 -noout -dates -in /etc/letsencrypt/live/zxpn.example.com/cert.pem`
ssl_protocols TLSv1.3 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_125_GCM_SHA256';
分享至: