Welcome! Log In Create A New Profile

Advanced

Re: negation in the map directive of nginx

Francis Daly
September 08, 2022 06:56PM
On Thu, Sep 08, 2022 at 01:25:20PM -0400, libresco_27 wrote:

Hi there,

> I'm working on rate limiting for specific group of client ids where if the
> client id is equal to XYZ don't map it, thus, the zone doesn't get
> incremented.

http://nginx.org/r/limit_req_zone: Requests with an empty key value are
not accounted.

It's probably easier to set the value to empty for those ones, and
not-empty for the rest.

> For ex -
> limit_req_zone $default_rate_client_id zone=globalClientRateLimit_zone:50k
> rate=10r/m sync;
> map $client_id $default_rate_client_id {
> "^(?!ZZZZZZ)$" "$1"
> }

map $client_id $default_rate_client_id {
ZZZZZ "";
default $client_id;
}

(or whatever value is wanted).

> But this doesn't seem to work. Is this the correct way to negate a
> particular string(ZZZZZ in this example)? Please let me know.

Negative regexes can be hard; it's simpler to avoid them entirely.

Cheers,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list -- nginx@nginx.org
To unsubscribe send an email to nginx-leave@nginx.org
Subject Author Posted

negation in the map directive of nginx

libresco_27 September 08, 2022 01:25PM

Re: negation in the map directive of nginx

Francis Daly September 08, 2022 06:56PM

Re: negation in the map directive of nginx

libresco_27 September 11, 2022 11:22AM

Re: negation in the map directive of nginx

Francis Daly September 11, 2022 06:58PM

Re: negation in the map directive of nginx

teodorescu.serban September 09, 2022 02:53AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 83
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready