Score:0

nginx rate global limit split between two groups?

tm flag

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.