Looking to returning a 302 Redirect if a file is above a certain size...

barntzen nginx-forum at nginx.us
Tue May 21 05:27:40 UTC 2013

Hey there,

I was looking for some guidance for a project I'm working on.

We're looking into CDNs here, and we are specifically looking for a decent
origin pull service that also supports denying by referrer to prevent
hotlinking. However, as it turns out almost all origin pull services
*except* a service we'll call ACF restrict you to 100MB or less.

As we're not looking to have bulletproof hotlinking protection, we've
determined that the best way to handle it is to serve files through the main
CDN (we'll call them FSL), but have our nginx cluster return a 302 redirect
if the file the "client" is requesting is over 100MB. I've confirmed with
FSL that they will honor and cache that 302, which would then send clients
to ACF in as clean a fashion as possible.

The long and short is: I'm trying to work out how to make nginx return a 302
if a file is over 100MB, which I'm told the Lua module should be capable of.
Seeking some advice on how to do so as I'm hopeless with Lua and my searches
turned up nothing.

~ Benjamin

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,239370,239370#msg-239370

More information about the nginx mailing list