Skip to content

全站HTTPS

全站HTTPS

目标

全量https

申请

腾讯云可以直接申请,TrustAsia 的 DVSSL 免费证书(只验证域名所有权)一年有效期,一天内发放

安装

参考腾讯云文档

  1. 下载证书,Nginx文件夹包括SSL证书文件 1_www.domain.com_bundle.crt 和私钥文件 2_www.domain.com.key
  2. crt文件和key文件保存到对应服务所在机器的 /etc/nginx/ca 目录下
  3. 对应域名的配置修改如下

    server {
        listen 443;
        server_name www.domain.com; # 填写绑定证书的域名
        ssl on;
        index index.html
        ssl_certificate /etc/nginx/ca/1_www.domain.com_bundle.crt;
        ssl_certificate_key /etc/nginx/ca/2_www.domain.com.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # 按照这个协议配置
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; # 按照这个套件配置
        ssl_prefer_server_ciphers on;
        location / {
            include uwsgi_params;
            uwsgi_pass localhost:port;
        }
    }
    

    在 http 的 server 下添加(暂时不加,做双支持)

    rewrite ^(.*) https://$host$1 permanent; # http请求重定向到https

  4. 测试配置 nginx -t

  5. 重启 Nginx 生效