一键LNMP 配置ssl

阿里云服务器、lnmp一件安装包环境、腾讯云免费证书

一,证书文件

/usr/local/nginx/conf/ssl/1_www.xiaoluge.top_bundle.crt      # 证书

/usr/local/nginx/conf/ssl/2_www.xiaoluge.top.key      # key

二,站点配置

执行 lnmp vhost add 按照提示流程走

选择自己的ssl安装  提示证书.crt全路径,key全路径

直到站点安装完毕 ,在网站对应的配置文件www.***.com.conf内部最下面多了一层server。

三,开始443端口

参考:https://www.cnblogs.com/xxoome/p/7115614.html

1,这是阿里云服务器的坑,在服务器内使用命令查看端口开启情况时,443端口是开的,但是阿里云的规则是关闭的,这个时候需要到阿里云服务器的后台进行开启。

后台=》云服务器ESC=》实例=》管理=》本实例安全组=》配置规则=》添加安全组规则

阿里云lnmp开启https,ssl配置方法详细流程 其他 第1张

2、http和https都可以打开网站,http不能跳转到https。

修改该网站的配置文件**.conf,在上面监控80端口的server内加上301

server

    {

        listen 80;

        #listen [::]:80;

        server_name www.xiaoluge.top ;

        index index.html index.htm index.php default.html default.htm default.php;

        root  /home/wwwroot/www.xiaoluge.top;

        include rewrite/other.conf;

        #error_page   404   /404.html;

        #加上这句跳转即可

       if ($scheme = http ) {

           rewrite ^(.*)$ https://$host$1 permanent;

       }

        # Deny access to PHP files in specific directory

        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php-pathinfo.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

        {

            expires      30d;

        }

        location ~ .*\.(js|css)?$

        {

            expires      12h;

        }

        location ~ /.well-known {

            allow all;

        }

        location ~ /\.

        {

            deny all;

        }

        access_log off;

    }

server

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值