Limit serving to responses only below certain size

Jonathan Matthews contact at
Wed Mar 6 15:30:07 UTC 2013

On 6 March 2013 13:28, Calin Don <calin.don at> wrote:
> Hi,
> Is there a way to server files only below a certain size?
> eg. Return 403 on files bigger than 5MB?

Assuming you're talking about local filesystem files, you might try to
proxy_pass back round to yourself, and do an if() based on

If you're already proxy'ing, you could use the same technique but
without the double nginx hit.

I'd personally look at /how/ too-large files are getting onto disk,
and fix that, however.

Jonathan Matthews // Oxford, London, UK

More information about the nginx mailing list