Maybe I am asking a poor question but I want to apply rate limit in nginx based on custom http header rather than IP based. My IP based configuration is working but I am not able to get around using custom http header. What I want is that if a particular header is present in http request then rate limiting should be applied otherwise not.
conf file
http {
limit_req_zone $http_userAndroidId zone=one:10m rate=1r/s;
location ^~ /mobileapp{
set $no_cache 1;
# set rate limit by pulkit
limit_req zone=one burst=1;
limit_req_status 429;
error_page 429 /50x.html;
}
}
However, rate limiting is applied even if there is no header present. P.S. userAndroidId is my request header.