Limit robots

António P. P. Almeida appa at perusio.net
Tue Jan 17 19:27:44 UTC 2012


On 17 Jan 2012 17h15 WET, lists at ruby-forum.com wrote:

> Your solution works great for rate limiting, but I need the requests
> to still be 200 return code when they are not limited.  Any ideas?

Yes. Try:

- error_page 418 @bots;
+ error_page 418 =200 @bots;

I.e.:

location / {
    error_page 418 =200 @bots;

    if ($is_bot) {
      return 418;  
    }
    ...
}

location @bots {
   limit_req zone=useragenttrack burst=100 nodelay;  
   ...
}

--- appa



More information about the nginx mailing list