Linux配置Nginx支持Https

Linux的Nginx目录一般在etc/nginx

新建证书存放目录

sudo mkdir cert

sudo chmod 777 cert

拷贝文件到cert

7301250_abc.cn.key

7301250_abc.cn.pem

 

进入./sites-enabled/目录

新建配置文件

sudo touch abc.cn

sudo chmod 777 abc.cn

vim abc.cn

复制粘贴配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
server {
    listen 443;
    server_name abc.cn;
 
    ssl on;
    ssl_certificate  cert/7301250_abc.cn.pem;
    ssl_certificate_key cert/7301250_abc.cn.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   /home/web/;
    index  index.html index.htm;
        #支持history模式
    try_files $uri $uri/ /index.html;
    }
 
    location /api {
        proxy_pass http://127.0.0.1:8215/api;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
          
        # 支持websocket   
    proxy_http_version  1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    }
}

 

重启nginx

sudo service nginx restart

posted @   卓扬  阅读(389)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示