Exclude ip's from Nginx limit_req zone

ASTRAPI nginx-forum at nginx.us
Wed Dec 24 19:36:50 UTC 2014


Thanks for your reply Maxim Dounin

So something like this ? :

Main nginx conf:

http {

    geo $limited {
        default           1;
        192.168.45.56/32  0;
        199.27.128.0/21  0;
        173.245.48.0/20  0;
        103.21.244.0/22  0;
        103.22.200.0/22  0;
        103.31.4.0/22  0;
        141.101.64.0/18  0;
        108.162.192.0/18  0;
        190.93.240.0/20  0;
        188.114.96.0/20  0;
        197.234.240.0/22  0;
        198.41.128.0/17  0;
        162.158.0.0/15  0;
        104.16.0.0/12  0;
    }

    map $limited $limit {
        1        $binary_remote_addr;
        0        "";
    }


And this on the domain config? :

server {

    limit_req_zone $limit zone=foo:1m rate=10r/m;
    limit_req zone=foo burst=5;

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



More information about the nginx mailing list