Help with nginx proxy store as a frontend MP4 Anycast CDN

Greg M gregm at
Thu May 2 07:12:02 UTC 2013


I have been reading up on the nginx documentation and also stackoverflow about creating an Anycast CDN based on nginx-frontends.

We currently use nginx on the backend, and Squid for caching images and mp4's - however Squid is incredibly difficult to cache the mp4's as it cant handle the moov atom's, and thus is always just proxying direct from our servers.

We've read that an nginx proxy "store" can actually store content locally - but how is that store defined and managed ?

For example, we have 6 CDN endpoints around the world, each with 200G of SSD space, so ideally we'd like nginx to cache around 50-70G of videos (out of a total of 1.2TB on the backend). Here is our basic config:

server {
        listen x.x.x.x:80;

  location ~ \.mp4$ {
    proxy_pass http://origin;
        proxy_store /cache/videocdn/$request_uri;
        proxy_store_access user:rw group:rw all:r;
        proxy_temp_path /cache/nginx;


The first question I have is - how do we limit how much this above configuration will hold ? Do we need to manually run a bash script that checks for old mp4's based on access time and purge ?

The final question is, how can we have all requests to initially check the local cache for content ? In the same way on this request was asked,11284,11284 Maxim advised its possible to return "X-Accel-Redirect" to the file in the store. We would also want this for in-progress caching attempts, for example if I requested on a 2nd machine, before the first machine's request for the same file has had a chance to fully cache in the store.

Thanks in advance for any assistance!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list