腾讯云和阿里云ssl配置https, http重定向到https

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yueruitao/article/details/85062300

腾讯云

https://cloud.tencent.com/document/product/400/4143

在腾讯云买过免费的SSL后

将证明文件2_www.xxx.com.key

server {
        listen 443;
        server_name www.domain.com; #填写绑定证书的域名
        ssl on;
        ssl_certificate 1_www.domain.com_bundle.crt;
        ssl_certificate_key 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 / {
            root   html; #站点目录
            index  index.html index.htm;
        }
    }

阿里云

https://help.aliyun.com/knowledge_detail/95491.html?spm=a2c4g.11186623.2.12.2d7a34f1UZLgHs

将证明文件1625398_www。****** **。com.key

阿里云比腾旭多一步还需要配置安全组的443

server {
 listen 443;
 server_name localhost;
 ssl on;
 root html;
 index index.html index.htm;
 ssl_certificate   cert/1625398_www.******.com.pem;
 ssl_certificate_key  cert/1625398_www.******.com.key;
 ssl_session_timeout 5m;
 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
 ssl_prefer_server_ciphers on;
 location / {
     root html;
     index index.html index.htm;
 }
}

HTTP跳转到HTTPS

再建一个server


server {
    listen       80;
    server_name  xxx.com www.xxx.com;
    rewrite ^(.*) https://$host$1 permanent;
}

猜你喜欢

转载自blog.csdn.net/yueruitao/article/details/85062300