Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple limit_req Directives

How do multiple limit_req directives work in nginx? If I have a given server context that has two or more limit_req directives, how does it work when just one rejects the request? Is it considered rejected at that point, or do all of the directives have to reject the request in order for it to be blocked?

http://nginx.org/en/docs/http/ngx_http_limit_req_module.html

like image 695
Brandon Avatar asked Jan 22 '26 05:01

Brandon


1 Answers

As you consider, official docs has no reference how multiple limit_req directives work within the same location.

But this NGINX Blog does:

You can include multiple limit_req directives in a single location. All limits that match a given request are applied, meaning the most restrictive one is used.

As far as I understood every client's request is counted against every limit_req directive in location. If any of limit_req directives discards the request due to limitations, then request is finally discarded.

P.S. actually, quiet important question to my mind... No idea why nobody bothers about that.

like image 161
mdraevich Avatar answered Jan 25 '26 10:01

mdraevich