You don't simply host the whole site with the CDN, just your content.
I just realized I answered a similar question a while back: What does akamaihd.net do?
Image by WikiMedia
So your site references
http://akamai/myfile.ext. This will request
akamai can then send an HTTP redirect to the actual content server.
Now, when that last step is cached, great, all future requests will go to the closest content server.
How does that work?
Let's assume this website:
<img src="http://cdn/oliver.png" />
I request this website from my own webserver. The
.html file is not hosted with
cdn. Neither is the DNS of my webserver.
So my browser got that HTML file and now parses it. It finds the referenced image and notes that it is located at
http://cdn/oliver.png. It requests that file.
To do that, it need to find the IP address of
cdn. In our example, that IP address is
With that IP address, it can connect to the
cdn server and request
cdn realizes, "that guy is from Germany!". So instead of sending me my awesome picture that I wanted, it sends me an HTTP redirect saying:
/oliver.png is not here. It's at
So my browser will ask
10.10.33.33 (which is hopefully closer to me) for the picture.
I'm not saying this is how ALL CDNs work, but it would be one approach.
You could also implement a DNS daemon that returns different results for a name lookup depending on the location of whoever sent the query.
But I doubt that this is done in practice. But maybe I just can't imagine how to properly set that up. See fluffy's answer for how that could work.
Who runs CDNs?
Most global players have their own content delivery network in a way (or so I would assume). Some providers just offload certain services to larger CDNs (like Microsoft does with MSDN downloads).
And this might somehow touch on your second subject.
Consider this, in the MSDN Microsoft offers product downloads. These downloads are then provided by Akamai. If you can determine the URL of that download, you can just download the product without ever getting in touch with Microsoft.
Is that a security issue? Not really, because what is being downloaded is still protected (by a product key).
But how about other data?
If your data is security relevant, then it isn't CDN material. If you don't want something to be available as widely as possible, don't put it in a CDN.