rate limit by header or API key

Francis Daly francis at daoine.org
Sat Mar 27 09:51:37 UTC 2021


On Thu, Mar 25, 2021 at 03:48:41PM -0500, Andy Meadows wrote:

Hi there,

> using nginx open source, is there an option to provide a custom rate limit
> by user agent, http header value, or an API key?  Looking for the best
> option to provide custom rate limits to named users, but the traffic is
> coming from unpredictable IP addresses.

"limit_rate" (http://nginx.org/r/limit_rate) can control the
kbps-response-writing speed of a single request, using whatever criteria
you like, using things that are available at response-writing time.

"limit_req" (http://nginx.org/r/limit_req) and limit_req_zone can control
the rate of incoming requests that are processed, using whatever criteria
you like, using things that are available at request-reading time.

I'm not aware of a way to trivially combine the two.

Cheers,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list