Nginx阻止用户代理
时间:2015-01-27 15:22 来源:linux.it.net.cn 作者:IT
有些时候,需要阻止某些用户代理访问网站,比如ab,wget,curl等等,这就需要使用到$http_user_agent变量。
修改nginx.conf
if ($http_user_agent ~* (Wget|ab) ) {
return 403;
}
if ($http_user_agent ~* LWP::Simple|BBBike|wget) {
return 403;
}
重启nginx
# /usr/local/nginx-1.7.0/sbin/nginx -s reload
(责任编辑:IT)
有些时候,需要阻止某些用户代理访问网站,比如ab,wget,curl等等,这就需要使用到$http_user_agent变量。 修改nginx.confif ($http_user_agent ~* (Wget|ab) ) { return 403; } if ($http_user_agent ~* LWP::Simple|BBBike|wget) { return 403; } 重启nginx# /usr/local/nginx-1.7.0/sbin/nginx -s reload(责任编辑:IT) |