创建黑名单目录

vim /etc/nginx/black.ip

写入拒绝访问IP地址

deny 113.110.148.137;
deny 113.116.11.227;
deny 113.110.149.253;
deny 113.110.150.246;
#IP 段则使用如下
deny 113.0.0.0/8;
deny 113.110.0.0/16;
deny 113.110.11.0/24;

配置Nginx文件

vim /etc/nginx/nginx.conf

写入黑名单配置

#黑名单
include /etc/nginx/black.ip;

重启Nginx配置

systemctl restart nginx