I'm looking for a way to limit Nginx for location to a number of requests per second independent of the origin IP. From my understanding the rate limiting feature is IP sensitive which cannot be turned off.

What would be the right approach here?

  • 2
    Does this answer your question? Nginx limit requests globally
    – AlexD
    Feb 8, 2022 at 14:44
  • From my understanding all these options are by IP. So it works if you have e.g. 10r/m from one IP, but what you having request from a /8 or even /0? Am I just missunderstanding the documentation maybe?
    – frlan
    Feb 9, 2022 at 11:49
  • All those options aren't by IP. The answer here uses a static word (global) to bucket the requests, so all requests will go in the same bucket and be limited independent of IP: serverfault.com/a/817165/362828 This part in the question is what makes it by IP: $binary_remote_addr. But that key can be set to anything (e.g. you could limit based on a cookie or the request url).
    – DylanYoung
    May 9, 2022 at 19:55

1 Answer 1


Like so

limit_req_zone global zone=global_limit:1k rate=50/s;

The global part is the key Nginx uses to bucket requests. By setting it to a static string (could be anything), rather than a variable, all requests will go into the same bucket.

To limit by IP, you would set it to $binary_remote_addr. You can rate limit on just about anything (see https://www.nginx.com/blog/dynamic-bandwidth-limits-nginx-plus-key-value-store/#Complete-Sample-NGINX-Configuratio for a complex example).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .