Exclude ip's from Nginx limit_req zone

Martin Frb nginx at mfriebe.de
Sun Dec 21 10:49:53 UTC 2014


> limit_conn_zone $binary_remote_addr zone=alpha:8m;
> limit_req_zone $binary_remote_addr zone=delta:8m rate=40r/s;
>
> Domain nginx conf:
>
> limit_conn alpha 5;
> limit_req zone=delta burst=80 nodelay;
>
>
> So a user can create only 5 connections per ip and can have 40
> requests with a burst up to 80 connections.
>
> Now i want to exclude Cloudflare ip's from this connection limits.


If memory serves right you can use

     location / {
         if ($remote_addr != 1.2.3.4) {
             error_page 404 = @no_whitelist;
             return 404;
         }
         # whitelisted
     }
     location @no_whitelist {
         limit_conn  adalpha 5;
     }



More information about the nginx mailing list