阿里云服务器、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 配置ssl

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

 

相关文章:

  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
  • 2022-01-20
  • 2021-09-19
  • 2021-04-06
  • 2021-12-16
  • 2021-09-15
猜你喜欢
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-11
  • 2021-08-28
  • 2021-12-23
相关资源
相似解决方案