limit_req and limit_conn in rewrite modules if statement

Nam nginx-forum at nginx.us
Mon Nov 18 20:57:19 UTC 2013


To elaborate a bit more, in a single location I may end up with something
like this...

set $Whitelisted "No";
if ($GeoList1 = allow) {
    set $Whitelisted "Yes";
}
if ($GeoList5 = allow) {
    set $Whitelisted "Yes";
}
if ($http_user_agent ~ (googlebot|bingbot)) {
    set $Whitelisted "Yes";
}
if ($Whitelisted ~* "No") {
    limit_conn conlimit-one 5;
    limit_req zone=limit-half burst=9;
}

So that I can allow both IPs and user agents to avoid getting limited.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,244781,244783#msg-244783



More information about the nginx mailing list