在nginx主配置文件中,创建一个ip名单文件,并设置规则,如下:
[root@iZt4nhti5umlzfk8lwhhwdZ conf]# pwd
/web/bin/nginx/conf
[root@iZt4nhti5umlzfk8lwhhwdZ conf]# cat blockip.conf
allow 101.37.16.42;
allow 113.107.238.0/24;
allow 106.42.25.0/24;
allow 183.222.96.0/24;
allow 117.21.219.0/24;
allow 116.55.250.0/24;
allow 111.202.98.0/24;
allow 111.13.147.0/24;
allow 122.228.238.0/24;
allow 58.58.81.0/24;
allow 1.31.128.0/24;
allow 123.155.158.0/24;
allow 106.119.182.0/24;
allow 113.207.76.0/24;
allow 117.23.61.0/24;
allow 118.212.233.0/24;
allow 111.47.226.0/24;
allow 185.254.242.0/24;
allow 116.211.155.0/24;
allow 116.140.35.0/24;
allow 103.40.7.0/24;
allow 182.23.208.0/24;
allow 203.205.138.0/24;
allow 1.255.41.0/24;
allow 112.90.216.0/24;
allow 1.255.100.0/24;
deny all;
在server段中包含这哥文件即可,就是这么简单........
这是简单的白名单设置
最简单的还是下面这种:
直接allow ip/或者加网段,deny ip/或者加网段即可...........................
参考博客:
https://blog.csdn.net/weixin_43566469/article/details/89381216?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task https://www.centos.bz/question/nginx-ip-whitelist/ https://www.cnblogs.com/yshyee/p/7389379.html https://www.cnblogs.com/lemon-le/p/9204691.html https://www.jianshu.com/p/1be19035e22a