# Help with nginx proxy store as a frontend MP4 Anycast CDN

**URL:** <https://www.ruby-forum.com/t/help-with-nginx-proxy-store-as-a-frontend-mp4-anycast-cdn/228662>\
**Category:** NGINX\
**Created:** [May 2, 2013, 9:13am UTC](https://www.ruby-forum.com/t/help-with-nginx-proxy-store-as-a-frontend-mp4-anycast-cdn/228662 "2013-05-02T09:13:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 2, 2013, 9:13am UTC](https://www.ruby-forum.com/t/help-with-nginx-proxy-store-as-a-frontend-mp4-anycast-cdn/228662/1 "2013-05-02T09:13:07Z")

</div>

Hi,

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;  
server\_name [cdn.blah.com](http://cdn.blah.com);

location ~ .mp4$ {  
mp4;  
proxy\_pass [http://origin](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  
[Nginx + proxy\_store + flv/mp4](http://forum.nginx.org/read.php?2,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  
[cdn.blah.com/1.mp4](http://cdn.blah.com/1.mp4) 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!

Regards,

Greg
