0

I've gone through the limit_req_zone docs and also searched through but haven't seen whether it's possible to do this with nginx rate limiting. I want to do the following:

  1. set a global rate limit ie. limit_req_zone global zone:general 10r/s

  2. let's say there's a vip group of whitelisted ip addresses. I want to split 5r/s amongst the vip group, and then everyone else has 5r/s to fight over.

Ideally I could making a mapping:

map $whitelist $non_whitelist_group {
    0     "non_whitelist"
    1     ""
  }

  map $whitelist $whitelist_group {
    0 ""
    1 "whitelist"
  }

  limit_req_zone $whitelist_group zone=whitelist:10m rate=5r/s;
  limit_req_zone $non_whitelist_group zone=non_whitelist:10m rate=5r/s;

But I believe using a static keys won't do what I want, it will apply the 5r/s globally. The typical $binary_remote_address wouldn't work in my case because I don't want it to be by IP address, I want it to be by essentially a whitelist flag.

0 Answers0