Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to serve the index.html file for my domain via a cdn (and a few other static pages).

Would it be possible to do this with an Amazon EC2 Instance and Rackspace Cloud Files?

I found something that sort of does this but only for an /images and /files directory:

server {
listen  80;
access_log /var/log/nginx/cdn.failverse.access.log;

location / {
   root /var/www/vhosts/domain2/public/cdn;
   index index.html;

    if  (!-e $request_filename)
            rewrite ^/images/(.*)$$1 redirect;
            rewrite ^/files/(.*)$$1 redirect;


It would be great if I could have the Cloud Files be part of my own subdomains ie. (If I have to use Rackspace Servers for everything that is okay too).


share|improve this question
Rackspace Cloud Files has CNAME support now--in fact you can simply create a CNAME for pointed to the domain of a CDN-enabled container, e.g., that's it--you don't need to host servers with Rackspace or have any other service. Note that Cloud Files is a storage service, not a site delivery platform, so there is no concept of an index file (or automatically indexing a container to get a file list). If you want index.html, you have to request /index.html. – MonkeeSage Aug 30 '11 at 19:55
Thanks MonkeeSage. That is exactly what I'm playing with now. I have CNAME setup right now but how would I tell ngnix to serve index.html and a javascript file directly from the cdn when a user goes to (so it serves when user requests – user94137 Sep 8 '11 at 18:00

Well, there's no point in doing a redirect to a CDN (as per your example config), because by the time the request/response has gone through your server, and then the browser makes a new request to the CDN and gets the response, you could just have sent the client the darned content and been done with it. There's also issues with trying to do this with proxy CDNs that would be entertaining to work around in a robust fashion.

The typical way of utilising a CDN is that all of the static assets (images, JS, CSS) can be served out of a subdomain (like and the pages that users directly request contain the links to the CDN assets on the separate domain. It is far more rare (though not unknown) to try to serve everything out of a CDN, but if you do want to go that way, you really have to serve everything -- no dynamic content, nothing. The closest you can come is to have your dynamic content on one domain, and your static pages on the CDN, and link between them, but quite honestly, that way lies probable madness without a very good automated site build and distribution system.

share|improve this answer
I understand why my request might be odd but I simply wanted to try to serve most of my content via cdn and then update via javascript as a test. – nobodytold Aug 28 '11 at 3:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.