• nginx配置不允许通过IP只允许通过域名进行访问


    在nginx.conf配置文件中加上(如果有了监听80端口的那就改为)

    http

    # 禁止通过ip地址访问
     server {
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name _;
        return 400;
    }
    # 允许通过域名访问-自动跳转到https
     server {
        listen 80;
        server_name 你的域名.com;
        rewrite ^(.*) https://$server_name$1 permanent;
    }

    https

    # 禁止通过ip地址访问-https
    server {
        listen 443 ssl default_server;
        listen [::]:443 ssl default_server;
        #ssl on;
        ssl_certificate 3935979_www.slience.com.pem;
        ssl_certificate_key 3935979_www.slience.com.key;
        server_name _;
        return 400;
    }
    server
      {
        listen 443 ssl;#监听端口
        server_name 你的域名.com;#域名
        index index.html index.htm index.php;
        ssl_certificate 你的证书.pem;
        ssl_certificate_key 你的证书key.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 /home/web/html;#你的站点目录
          location ~ .*.(php|php5)?$
        {
          #fastcgi_pass unix:/tmp/php-cgi.sock;
          fastcgi_pass 127.0.0.1:9000;
          fastcgi_index index.php;
          include fastcgi.conf;
        }
        location ~ .*.(gif|jpg|jpeg|png|bmp|swf|ico)$
        {
          expires 30d;
      # access_log off;
        }
        location ~ .*.(js|css)?$
        {
          expires 15d;
       # access_log off;
        }
        access_log off;
      }

    之后reload一下nginx即可

  • 相关阅读:
    CF1132G
    CF1129B
    CF1131G
    CF1109D
    CF1110H
    CF1106F
    my.cnf 配置
    mysql 导入导出
    mysql 批量删除表数据
    国内开源镜像站
  • 原文地址:https://www.cnblogs.com/netlock/p/15094231.html
Copyright © 2020-2023  润新知