We try to save nginx resources by limiting the number of requests per second:
http {
limit_req_zone $binary_remote_addr zone=gulag:10m rate=2r/s;
server
{
location / {
proxy_pass http://0.0.0.0:8181;
limit_req zone=gulag burst=40;
}
}
}
However, most employees in our company are also heavy users of our own website. Since everyone in the company appear to come from the same ip address were getting 503 errors because nginx thinks all the traffic is coming from one user. Can we add our ip as an exception to the requests per second limit?
Yes, you can. Just a quote from the documentation:
The key is any non-empty value of the specified variable (empty values are not accounted).
So you can achieve your goal by using geo and map modules like this:
geo $limited_net {
default 1;
10.1.0.0/16 0;
}
map $limited_net $addr_to_limit {
0 "";
1 $binary_remote_addr;
}
limit_req_zone $addr_to_limit zone=gulag:10m rate=2r/s;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With