CDN CNAMEs not resolving to customer origin

cdn

I have set up an Edgecast CDN to mirror all my static content. Because I use the root of my domain (donaldjenkins.com) to host my main site—using Google Analytics which sets cookies—I've stored the corresponding static files in a separate cookieless domain (donaldjenkins.info) which is used only for this purpose. I've set it up (using this guide for general guidance), with the following structure, based on a combination of customer origin and CDN origin to make the most of the chosen short domain name and provide meaningful URLs:

  1. http://donaldjenkins.info:80 is set as the customer origin for the content stored in the CDN at directory http://wac.62E0.edgecastcdn.net/8062E0/donaldjenkins.info;

  2. I've then set up various subdomains of a separate domain, the conveniently-named cdn.dj, as CDN-origin Edge CNAMEs for each of the corresponding static content types:

    • js.cdn.dj points to the origin directory http://wac.62E0.edgecastcdn.net/0062E0/donaldjenkins.info/js;
    • css.cdn.dj points to the origin directory http://wac.62E0.edgecastcdn.net/0062E0/donaldjenkins.info/css;
    • images.cdn.dj points to the origin directory http://wac.62E0.edgecastcdn.net/0062E0/donaldjenkins.info/images

and so on. This results in some pretty nice, short, clear URLs.

The DNS zone file for cdn.dj (yes, it's a real domain name registered in Djibouti) is set properly:

cdn.dj          43200   IN   A       205.186.157.162     
css.cdn.dj      43200   IN   CNAME   wac.62E0.edgecastcdn.net.
images.cdn.dj   43200   IN   CNAME   wac.62E0.edgecastcdn.net.
js.cdn.dj       43200   IN   CNAME   wac.62E0.edgecastcdn.net.

The DNS resolves to the Edgecast URL:

$ host js.cdn.dj
js.cdn.dj is an alias for wac.62E0.edgecastcdn.net.
wac.62E0.edgecastcdn.net is an alias for gs1.wac.edgecastcdn.net.
gs1.wac.edgecastcdn.net has address 93.184.220.20

But whenever I try to fetch a file in any of the directories to which the CNAME assets map, I get a 404:

$ curl http://js.cdn.dj/combined.js
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title>404 - Not Found</title>
    </head>
    <body>
        <h1>404 - Not Found</h1>
    </body>
</html>

despite the fact that the corresponding customer origin file exists:

$ curl http://donaldjenkins.info/js/combined.js

fetches the content of the combined.js file. Yet it's been more than enough time for the DNS to propagate since I set up the CDN.

There's obviously some glaring mistake in the above-described setup, and I'm a bit of a novice with CDNs—but any suggestions would be gratefully received.

Best Answer

It doesn't have anything to do with DNS. You shouldn't be using CDN origin servers. All your content is on your customer origin server. With CDN origin servers you manually (via FTP) upload content to it.

So, delete the CDN origin servers. Delete the cdn.dj A record (assuming you just want to use cdn.dj for cdn)

Then follow these instructions from http://wiki.mediatemple.net/images/EdgeCast_HTTP_Small_Object_Guide_3.03.pdf:

To configure our edge servers to recognize your CNAME

  1. Navigate to the Edge Cnames page, which can be found on the HTTP Small Object tab of the MCC.
  2. In the New Edge Cname option, type the name of the desired CNAME record. The CNAME should be specified in lower-case letters and should not include the protocol (i.e. http://). [ For example js.cdn.dj. -MAW ]
  3. Select whether the specified CNAME will point to a customer origin or CDN origin server. [ In your case customer origin. -MAW ]
  4. By the Points to option, select the root location on the origin server to which the CNAME will be pointed. If you would like to indicate a specific folder, then you should type a forward slash (/) followed by the path to the desired folder. [ For examample: http://donaldjenkins.info/js for js.cdn.dj. -MAW ]
  5. Click Add.
  6. Make sure that a CNAME record that points to the same domain has been registered on your DNS server. This CNAME record must match the name assigned to your edge CNAME. [ You've already done this. -MAW ]

Then this is what happens:

  1. A web browser makes a request for http://js.cdn.dj/combined.js
  2. The CNAME sends the request to wac.62E0.edgecastcdn.net.
  3. wac.62E0.edgecastcdn.net looks at the HTTP host header and sees js.cdn.dj.
  4. wac.62E0.edgecastcdn.net looks through its config and finds a masking URL for js.cdn.dj with customer origin server http://donaldjenkins.info/js
  5. wac.62E0.edgecastcdn.net acts as though it just got a request for the URL http://wac.62E0.edgecastcdn.net/8062E0/donaldjenkins.info/js/combined.js.
  6. combined.js is served from the cache or retrieved from http://donaldjenkins.info:80/js/combined.js and then served.