set $flag 0; if ($http_referer ~* "特征字") { set $flag ${flag},1; } if ($http_user_agent ~* "spider") { set $flag $flag,2; } if ($flag = "0,1,2") { return 403; }
nginx 的多条件复合情况下的屏蔽策略
回复
set $flag 0; if ($http_referer ~* "特征字") { set $flag ${flag},1; } if ($http_user_agent ~* "spider") { set $flag $flag,2; } if ($flag = "0,1,2") { return 403; }
根据 User-Agetn 为空,或者特定字符串 ,屏蔽之
SetEnvIfNoCase User-Agent ^$ GoAway SetEnvIfNoCase User-Agent 字符串 GoAway <Directory /目录> Order allow,deny Allow from all Deny from env=GoAway </Directory> 也可以参考 /user-agent-apache-ddos.html