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

Brian08275660 nginx-forum at nginx.us
Fri Oct 25 21:14:16 UTC 2013


Hi Jader,

Thanks a lot, that looks like a nice solution!

I barely know how to build regex expressions, and I'm too lazy to learn just
right now. Just a final question: Actually they will send me any value from
2X to 25X, but that could even increase to more than 25. I would like a
simpler and more open REGEX, something like:

If it is something that includes an "X"

I will use it as this:

map $arg_capacity $my_default_key{   If it is something that includes an "X"
           ""; default $http_x_forwarded_for;}

Simple as that. This would catch any case, from 2X to 1000000000X. Actually
it would catch even illegal values. But that is not a problem for me, cause
in my java code that follows Nginx I'm validating the value they send me
anyway, so I don't mind if they send me a value like "-1X" because my app
would return an error status code and force them to send me a valid value
anyway. The important thing is that Nginx should apply the limit if the
received value is not empty, and asking if it contains an "X" covers that
boolean question.

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



More information about the nginx mailing list