mingetty

 

1. 在   /etc/nginx/nginx.conf  配置文件的server模块里添加匹配  ( 和location同一级 )

       if ($remote_addr !~ ^(192.168.0.*|127.0.0.1)) {
         rewrite ^.*$ /errorPage/upgrade.html last;
        }

用这种方法, 除去上面包含的ip外的所有客户端的请求都不可以. 包括 POST请求.

 

 有代理的话, 判断代理前客户端ip进行限制

 

2. 在   /etc/nginx/nginx.conf  配置文件的server里location里做限制

    server {
       listen 80;
       server_name tty.bszhihui.com;
       location / {
                allow 111.198.29.223;
                deny all;
            root   /data/wu/web/;
            index  default.php  index.php index.html;
                }

        error_page  404 403     /error.html;

        location = /error.html {
        }
        }

用这种方法, 除了允许的ip可以,拒绝的ip不可以, 规则是从上往下. 但是禁止的 GET请求, POST 不限制. 

 

默认这些参数配置都是针对请求客户端的, 有代理时参考下面

 

分类:

技术点:

相关文章:

  • 2021-09-15
  • 2021-08-15
  • 2022-12-23
  • 2021-11-06
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
  • 2021-07-07
  • 2022-01-11
  • 2021-08-27
  • 2021-10-05
相关资源
相似解决方案