騰訊雲Nginx配置HTTPS


1. 獲取證書

  騰訊雲->SSL證書管理->申請、下載證書,放到nginx的conf文件夾下

 

2.修改nginx.conf

  

# 監聽80端口HTTP請求,全部跳轉到HTTPS
server {
        listen       80;
        if ($host = "www.xjcode.com"){
                return 302 https://www.xjcode.com$request_uri;
        }
        return 302 https://$host$request_uri;
}

  

server {
        listen       443;
        server_name  xxx.xxx.com;

        ssl          on;
        ssl_certificate 1_xxx.xjcode.com_bundle.crt;
        ssl_certificate_key 2_xxx.xjcode.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;

        root /www/xxx/public;
        location / {
             index  index.php index.html index.htm;
             try_files $uri https://$host$1/ /index.php?$query_string;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

    }

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM