limit_req_zone: How to apply only to some requests containing some string in the URL?

Francis Daly francis at
Wed Oct 23 16:42:25 UTC 2013

On Wed, Oct 23, 2013 at 08:56:33AM -0400, Brian08275660 wrote:

Hi there,

> Could you please give me an example? A few lines of code would be great!

Completely untested, but something like:

  map $arg_key $key_ends_in_02X {
    default "";
    ~02X$ "A";

(where "A" might be, for example, $binary_remote_addr, if you want to
limit the requests per client IP, rather than enforce the limit across
all clients where "key" ends "02X")

and then

  limit_req_zone $key_ends_in_02X zone=two:10m rate=2r/s;


  limit_req zone=two;

should probably do what you asked for.

If anything is unclear or broken, and the documentation doesn't make
it clear how it should be, then feel free to respond pointing out which
specific parts need fixing.


Francis Daly        francis at

More information about the nginx mailing list