limit_req inside a if block - Not allowed ?
Maxim Dounin
mdounin at mdounin.ru
Fri Apr 16 04:50:32 MSD 2010
Hello!
On Thu, Apr 15, 2010 at 04:21:47PM +0530, Harish Sundararaj wrote:
> My objective is to apply the limit_req for all requests except Googlebot.,
> So had something like this inside a location context:
>
>
> limit_req_zone $binary_remote_addr zone=one:2m rate=25r/m; #This piece
> of conf is inside a http context
>
> #The below code is inside a location context
>
> if ($http_user_agent !~ Googlebot) {
> limit_req zone=one burst=4;
> }
>
> But I get a error :
> [emerg]: "limit_req" directive is not allowed here
>
> Is there anyway i can achieve this ?
Try this:
location / {
error_page 410 = @nolimit;
if ($http_user_agent ~ Googlebot) {
return 410;
}
limit_req zone=one burst=4;
...
}
location @nolimit {
...
}
See here for details:
http://wiki.nginx.org/IfIsEvil
Maxim Dounin
More information about the nginx
mailing list