TLDR: when I make this DNS record:
whatever.mydomain.com. IN CNAME biglongjibberstring.r89.cf2.rackcdn.com.
How does Rackspace know that this random host name I've chosen should go to my Cloud Files container/account as opposed to another customer?
I just tested a simple example of using Cloud Files with Rackspace. I made a Cloud Files "Container" and enabled the "Static Website" option. I uploaded an example image and an example index.html file. These files in this container are now available at this crazy-long URL, which the UI tells me I can use as the CNAME for my domain:
And sure enough, adding a CNAME record like:
whatever.mydomain.com. IN CNAME biglongjibberstring.r89.cf2.rackcdn.com.
Browsing to http://whatever.mydomain.com/ works (tested the home page and the image). But how could it possibly know that when it sees a request for "whatever.mydomain.com" (in the HTTP Host header) that it is meant for my particular cloud files container?
It seems to have something to do with DNS, since if I just put "blah.example.com" in my hosts file with the IP address that biglongjibberstring.r89.cf2.rackcdn.com. resolves to - that does not work (gives an error about Invalid URL - appears to be coming from Akamai). The only way I could possibly see this working is if somehow the DNS lookup for whatever.mydomain.com was somehow transmitting back to Rackspace/Akamai DNS servers this relationship between "whatever.mydomain.com" and "biglongjibberstring.r89.cf2.rackcdn.com.". But I've never seen this approach and I don't even think that DNS lookup that goes back to Rackspace/Akamai actually contains the information necessary for this (although I could be wrong about that).
Does anyone know what kind of black magic is going on here?
After observing the behavior, my best guess at what they could reasonably be doing is this:
When an HTTP request arrives at one of the CDN nodes and the request has an unknown
Host
header they themselves look up the name in theHost
header.If this name turns out to be a
CNAME
referring to a known name (on the form<identifyinginformation>.rackcdn.com.
) they associate the name from theHost
header with the appropriate resource, otherwise they return an error.This is speculative but that's what I can think of that fits what is technically viable as well as the observed behavior. The documentation at Rackspace does not specify how it actually works, but hopefully their support could help.
If anyone wants to experiment further on their own a Rackspace employee mentions the URL http://124f4d373d9886355285-0dddf6f52a326dca397d3ae1202a22fd.r49.cf2.rackcdn.com/1_logs_dir.png as an example in the comments at the documentation page linked above. Just add a
CNAME
to the host part of that URL, modify the URL accordingly and try it out.