NGINX配置HTTPS证书

环境

访问域名: www.xingyongsheng.top xingyongsheng.top
证书类型: 在阿里云申请的免费证书(上面两个域名申请其中之一即可)
NGINX版本: nginx/1.16.1
操作系统: CentOS Linux release 7.8.2003 (Core)
代码路径: /data/xdocs/public
证书路径: /data/nginx_certs

申请及下载证书

1 申请和下载
在这里插入图片描述

2 上传到服务器上

[root@qingcloud /data/nginx_certs]# ls -rlht --full-time
total 12K
-rw-r--r-- 1 root root 3.6K 2021-02-07 10:23:38.000000000 +0800 5172151_www.xingyongsheng.top.pem
-rw-r--r-- 1 root root 1.7K 2021-02-07 10:23:38.000000000 +0800 5172151_www.xingyongsheng.top.key
-rw-r--r-- 1 root root 4.0K 2021-02-07 10:38:27.531561844 +0800 5172151_www.xingyongsheng.top_nginx.zip

修改NGINX配置文件

[root@qingcloud ~]# cat  /etc/nginx/conf.d/xingyongsheng-top.conf
server {
    listen      443 ssl;
    server_name xingyongsheng.top www.xingyongsheng.top;
    root        html;
    index       index.html index.htm;
    
    ssl_certificate            /data/nginx_certs/5172151_www.xingyongsheng.top.pem;
    ssl_certificate_key        /data/nginx_certs/5172151_www.xingyongsheng.top.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   /data/xdocs/public;
        index  index.html index.htm;
    }
}

server {
    listen 80;
    server_name xingyongsheng.top www.xingyongsheng.top;
    rewrite ^(.*)$ https://$host$1 permanent;
    location / {
        index index.html index.htm;
    }
}

参考资料

https://help.aliyun.com/document_detail/98728.html?spm=5176.14113079.0.dexternal.3e4756a7ITEnst
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

凯尔kyle

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值