I have some basic questions regarding configuring the CDN. I am using Amazon CloudFront for that.
1) Let's suppose my website is example.com. In the origin of cloudfront, do I mention example.com as the origin or create a CNAME like cdn.example.com which points to the server and then enter cdn.example.com as the origin?
2) Once the configuration is done, do I redirect example.com to the cloudfront domain like dxxxxxx.cloudfront.net?
3) I will update all the links in my website to http://dxxxxxx.cloudfront.net/xxx. Now when I browse example.com, I will be redirected to cloudfront. But cloudfront is also using the example.com as the origin. Isn't it like cloudfront is trying to pull data from itself? Won't that create a dead loop?
I am not able to get my head around this. I will be really grateful if someone could help. Thanks!!
Here is how it works.
Step 3, and 4 are not part of the CDN integration process. Also, the subdomain cdn.example.com is not a requirement. You can use some other subdomain, or some other domain. For example, the following are valid:
cdn2.example.com
static-assets.example.com
static.assets.example.com
images.example.parent-company-website.com
Similarly, it is not a requirement to fetch assets from example.com only. You can specify my-other-website.net as origin, and cloudfront will happily fetch resources from there for your example.com site.
In your scenario, all of the following are not dependent on each other. You can change any or all of these and the process will not break providing you made necessary adjustments to the configuration and the code.
Your website: example.com
CDN origin: example.com (since currently assets are at this host)
Pull Zone: http://dxxxxxx.cloudfront.net/
CNAME Host: cdn.example.com
Hope this clears the picture.