1. 程式人生 > >騰訊雲和阿里雲ssl配置https, http重定向到https

騰訊雲和阿里雲ssl配置https, http重定向到https

騰訊雲

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;
}