3

I'm using CloudFront as a CDN, and my website as an origin for pulls. Basically, I have cdn.mydomain.com pointing over to Cloudfront, and Cloudfront pulls any requests from www.mydomain.com. However, I don't want users to be able to request things like cdn.mydomain.com/default.aspx or cdn.mydomain.com/Robots.txt. In fact, I only want to serve up images, JavaScript files, CSS stylesheets, and other static content.

What I've figured out is somewhat of a hack, though it appears to work. I set the Default behavior to point to an Origin called Null. The Null origin points to null.mydomain.com which doesn't exist, thus any request will just error out. Then, I setup other behaviors for each directory in my website that I want to whitelist. It looks like this:

enter image description here

This appears to work, but is there a better, less hacky solution that I'm missing?

Mike Christensen
  • 965
  • 1
  • 11
  • 21

1 Answers1

1

Yes, a less hacky approach is to just put your static files into an S3 bucket and use the S3 bucket as the origin pull. Leave your webserver out of it altogether.

Mike Brant
  • 581
  • 5
  • 3