Nginx 屏蔽 IP
blacklist.conf
nginx
deny 127.0.0.1;
# 屏蔽单 IP
deny 127.0.0.1 192.168.1.1;
# 屏蔽多 IP
deny 127.0.0.0/8;
# 屏蔽网段 127.0.0.1 ~ 127.255.255.254
deny 127.255.0.0/16
# 屏蔽网段 127.255.0.1 ~ 127.255.255.254
deny 127.255.255.0/24
# 屏蔽网段 127.255.255.1 ~ 127.255.255.254
配置
LNMP
全局屏蔽
/usr/local/nginx/conf
中创建blacklist.conf
各网站conf
分别添加:
nginx
include blacklist.conf;
独立屏蔽
/usr/local/nginx/conf
中创建blacklist
目录并在目录中创建各站点domain.com.conf
各网站conf
分别添加:
nginx
include blacklist/domain.com.conf;
DNMP
全局屏蔽
/path/dnmp/services/nginx/conf.d
中创建blacklist.conf
各网站conf
分别添加:
nginx
include conf.d/blacklist.conf;
独立屏蔽
/path/dnmp/services/nginx/conf.d
中创建blacklist
目录并在目录中创建各站点domain.com.conf
nginx
include conf.d/blacklist/domain.com.conf;