Nginx limit_rate based on file extension

Francis Daly francis at
Sat Jun 25 00:38:58 UTC 2016

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?

Francis Daly        francis at

More information about the nginx mailing list