nginx limit_rate if in location - strange behaviour - possible bug ?

Maxim Dounin mdounin at mdounin.ru
Wed Oct 9 15:46:44 UTC 2013


Hello!

On Wed, Oct 09, 2013 at 05:21:51PM +0300, Bozhidara Marinchovska wrote:

[...]

> I'm using limit_rate case if in location. Regarding documentation
> "if in location" context is avaiable.
> 
> My configuration is as follows:
> 
> location some_extension {
> 
> # case 1
> if match_something {
> root ...
> break;
> }
> 
> # case 2
> if match_another {
> root ...
> break;
> }
> 
> # else (case3)
> root ...
> something other ...
> here it is placed also limit_rate / limit_after directives
> }
> 
> There is a root inside location with a (strong) reason :) (nginx
> pitfails case "root inside location block - BAD").
> 
> When I open in my browser http://my.website.com/myfile.ext it
> matches case 3 from the cofiguration. Limit_rate/limit_after works
> correct as expected.
> I want case1 not to have limit_rate / limit_after.

The limit_rate directive is somewhat special (== wierd), and a 
limit once applied on a location matched is preserved for future 
use.  Further matches with different limit_rate set doesn't 
influence the limit actually used.

If you want to override limit_rate on a specific condition, use 

    set $limit_rate <rate>;

instead, see http://nginx.org/r/limit_rate.

-- 
Maxim Dounin
http://nginx.org/en/donation.html



More information about the nginx mailing list