limit_req is not working in virutal location?

Francis Daly francis at
Thu Jan 11 13:11:36 UTC 2018

On Thu, Jan 11, 2018 at 03:32:07AM -0500, pva wrote:

Hi there,

I'm slightly guessing, so apologies if I mislead you and hopefully someone else
will correct this if necessary...

> Hi. Could you, please, explain why limit_req in @limitspeed location is not
> working in case of redirect to @allowed virtual location and works in case I
> copy @allowed virtual location contents inside @limitspeed? 

I think that "return" happens before, and therefore effectively overrides

You'll want your "limit_req" effective in a location where some real
work is done to create the response, in order for it to actually limit
the response rate.

(So either replace "return" with the content of the other location,
as you did; or add the limit_req into the other location.)

Francis Daly        francis at

More information about the nginx mailing list