Limit robots
António P. P. Almeida
appa at perusio.net
Fri Jan 13 13:50:48 UTC 2012
On 13 Jan 2012 13h36 WET, nginx-forum at nginx.us wrote:
> Hello,
>
> Is there a chance to limit robots to 1 request per second?
> The down below does not work: [emerg] "limit_req" directive is not
> allowed here
Yes. Try:
At the *http* level:
limit_req_zone $http_user_agent zone=useragenttrack:1m rate=1r/s;
map $http_user_agent $is_bot {
default 0;
~[a-z]bot[^a-z] 1;
}
At the server level:
location / {
error_page 418 @bots;
if ($is_bot) {
return 418;
}
...
}
location @bots {
limit_req zone=useragenttrack burst=100 nodelay;
...
}
Cf: http://wiki.nginx.org/HttpLimitReqModule
--- appa
More information about the nginx
mailing list