前言
申請地址:https://console.cloud.tencent.com/ssl
騰訊云配置https檔案:https://cloud.tencent.com/document/product/400/35244
一、申請
點擊免費申請

填寫資訊

提交

下載證書

已在 SSL 證書管理控制臺 中下載并解壓縮 cloud.tencent.com 證書檔案包到本地目錄,
解壓縮后,可獲得相關型別的證書檔案,其中包含 Nginx 檔案夾和 CSR 檔案:
重點(Nginx 下檔案)

二、將檔案放入Nginx目錄下
- Nginx conf目錄下
cd /usr/local/nginx/conf

2. 創建一個cart目錄
mkdir cart

3. 將檔案拉進去

進入nginx.conf
vim /usr/local/nginx/conf/nginx.conf

原本是注釋了的,解開注釋就行了
Https配置代碼
# HTTPS server
#
server {
listen 443 ssl;
server_name lanys.love;
ssl_certificate cart/1_lanys.love_bundle.crt;
ssl_certificate_key cart/2_lanys.love.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:80/;
root html;
index index.html index.htm;
#proxy_redirect off;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_pass http://127.0.0.1:80/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
解釋代碼
server {
listen 443 ssl; 埠,需要開啟防火墻
server_name lanys.love; 指定域名
ssl_certificate cart/1_lanys.love_bundle.crt; 剛剛創建cart目錄下的 1_lanys.love_bundle.crt 檔案
ssl_certificate_key cart/2_lanys.love.key; 剛剛創建cart目錄下的 2_lanys.love.key 檔案
ssl_session_cache shared:SSL:1m; 默認不用管
ssl_session_timeout 5m; 默認不用管
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:80/; 指定你要配置的https的地址
root html; 默認不用管
index index.html index.htm; 默認不用管
proxy_set_header Host $host; 頭部配置,可以直接拿
proxy_set_header X-Real-IP $remote_addr; 頭部配置,可以直接拿
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 頭部配置,可以直接拿
proxy_set_header X-Forwarded-Proto $scheme; 頭部配置,可以直接拿
}
測驗


問題
如果是你指定是你自己的網站,需要手動將路徑改為https的,

三、總結
申請地址:https://console.cloud.tencent.com/ssl
騰訊云配置https檔案:https://cloud.tencent.com/document/product/400/35244
官網配置更詳細點!!!
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/298916.html
標籤:其他
下一篇:H5新增了哪些新特性
