运维部署

免费SSL证书部署实验:从HTTP到HTTPS的完整流程

2025-02-20 | Nginx + Let's Encrypt
操作步骤
  • 安装Certbot工具:`sudo apt install certbot python3-certbot-nginx`
  • 生成证书:`certbot certonly --webroot -w /var/www/zxpn -d zxpn.example.com`
  • 配置Nginx:
  • ```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:
  • nginx server { listen 80; server_name zxpn.example.com; return 301 https://$host$request_uri; }
    注意事项
    - 证书有效期90天,需设置自动续期任务
    - 添加Cron任务:`0 12 * * * /usr/bin/certbot renew --quiet`
    - 测试证书续期:`certbot renew --dry-run`
    
    验证方法
    
  • 浏览器访问:地址栏显示小锁图标
  • 使用SSL Labs测试:https://www.ssllabs.com/ssltest/
  • 检查证书信息:`openssl x509 -noout -dates -in /etc/letsencrypt/live/zxpn.example.com/cert.pem`
  • 性能优化 - 启用HTTP/2:`listen 443 ssl http2;` - 优化SSL密码套件:
    nginx 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'; ``` 升级HTTPS后,网站安全性评分从65分提升至95分,SEO排名提升约15%。
    分享至:

    相关学习推荐

    前端开发

    学习动态页移动端适配实验:从错位到完美显示

    2024-10-12
    查看详情
    前端开发

    微信开放平台登录集成实验:从0到用户一键登录

    2025-04-25
    查看详情