Nginx limit_rate based on file extension

Hello,

I wonder is there any way to limit_rate based on file extension in
Nginx,
for example, putting different rate limit rules on flv and mp4?

I’ve tried this, but somehow returned file not found

location ~* .(flv|f4v)$ {
limit_rate_after 1m;
limit_rate 80k;
}

location ~* .(mp4|m4v)$ {
limit_rate_after 3m;
limit_rate 80k;
}

Your help is really appreciate!

Posted at Nginx Forum:

On Fri, Jun 24, 2016 at 03:10:08AM -0400, charles13 wrote:

Hi there,

I wonder is there any way to limit_rate based on file extension in Nginx,
for example, putting different rate limit rules on flv and mp4?

I’ve not tested it, but it should Just Work.

limit_rate can work in location{}, so put it in the location{} that
handles the urls that you care about.

I’ve tried this, but somehow returned file not found

location ~* .(flv|f4v)$ {
limit_rate_after 1m;
limit_rate 80k;
}

One request is handled in one location. Only the config in, or inherited
into, that location counts.

What is “root” set to here? What file on your filesystem do you want
nginx to return?

f

Francis D. [email protected]