How to rate-limit in nginx, but including/excluding certain IP addresses?

Posted by Jason Cohen on Server Fault See other posts from Server Fault or by Jason Cohen
Published on 2010-09-02T19:11:59Z Indexed on 2011/02/24 23:26 UTC
Read the original article Hit count: 399

Filed under:
|

I'm able to use limit_req to rate-limit all requests to my server.

However I'd like to remove the rate restriction for certain IP addresses (i.e. whitelist) and use a different rate restriction for certain others (i.e. certain IPs I'd like as low as 1r/s).

I tried using conditionals (e.g. if ( $remote_addr = "1.2.3.4" ) {}) but that seems to work only with rewrite rules, not for rate-limit rules.

© Server Fault or respective owner

Related posts about nginx

Related posts about rate-limiting