• 配置Nginx部署静态资源和自动跳转到https


    一、首先在阿里云后台添加域名解析:  

    二、两个网站的静态资源在以下目录:

       /www/temp/blog/public

    三、在服务器端配置nginx:

      cd /etc/nginx/conf.d 添加两个文件

      以admin-locusy-top.conf为例,添加以下配置(注意图片等资源文件的目录,所在的static目录是在public下的):

    server {
      listen 80;
      server_name admin.locusy.top;
      root /www/temp/blog/public/admin;
      index index.html;
      location ~ .*.(jpg|jpeg|gif|png|ico|css|js|pdf|txt)$ {
        root /www/temp/blog/public;
        autoindex on;
      }
    }

      www-locusy-top.conf 增加了https协议的配置:

    server {
            listen 80;
            server_name www.locusy.top;
            root /www/temp/blog/public/client;
            index index.html;
            location ~ .*.(jpg|jpeg|gif|png|ico|css|js|pdf|txt)$ {
                    root /www/temp/blog/public;
            }
            rewrite ^(.*)$  https://$host$1 permanent;
    #       return 301 https://www.locusy.top$request_uri;
    }
    
    server {
            listen 443;
            server_name www.locusy.top;
            ssl on;
            ssl_certificate   cert/1652724_www.locusy.top.pem;
            ssl_certificate_key  cert/1652724_www.locusy.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;
            root /www/temp/blog/public/client;
            index index.html;
            location ~ .*.(jpg|jpeg|gif|png|ico|css|js|pdf|txt)$ {
                    root /www/temp/blog/public;
            }
    
    #       if ($ssl_protocol = "") {
    #               rewrite ^(.*) https://$host$1 permanent;
    #       }
    }

    三、重启nginx:

      nginx -s reload

    四、打开网页:

      locusy.top

      admin.locusy.top

  • 相关阅读:
    ZooKeeper 相关知识
    zookeeper 启动和停止脚本
    es 6.4.3 版本的es的处理方式
    SpringBoot启动使用elasticsearch启动异常:Received message from unsupported version:[2.0.0] minimal compatible
    windows下安装elasticsearch-6.4.3和elasticsearch-head插件
    二项式公式
    计算公式
    大规模数据如何检索?
    设计数据服务:为报表服务提供服务接口
    win10 桌面快捷键技术
  • 原文地址:https://www.cnblogs.com/angelatian/p/10158468.html
Copyright © 2020-2023  润新知