前言
申请地址: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 官网配置更详细点!!!
|