Sunday, September 29, 2013

Creating custom error pages in amazon cloudfront

Advertisements

You know Amazon is a company who introduce new features often. Recently they came up with custom error page for cloudfront cdn. In this post we will see how to create a custom error page for 404(page not found) errors.

Open the cloudfront distribution
Click on error pages.










Click on create custom error page.

Creating custom error pages in amazon cloudfront







On HTTP error code, Select 404:Not Found from the drop down list.

Creating custom error pages in amazon cloudfront














You can leave the default caching time as 30 seconds.

Response page path:
This is the most important one. Your cloudfront distribution will have a origin bucket(if you are using amazon s3 as origin). In the same bucket you have to create a folder and inside that u need to keep the html page you want to show for the 404  errors.

Creating custom error pages in amazon cloudfront










in this case 404.html is
Sorry. The object you are looking for is currently unavailable. Please try later.

You have to give proper file/folder permissions(public) on the error pages.
If you want to give a error response you can set it. In this example we are sending 200:OK

Now, if you give a wrong cloudfront url, you can see the configured error page.

Creating custom error pages in amazon cloudfront












That's it. This is just a basic example. You can modify a lot. Have fun.

No comments:

Post a Comment

Be nice. That's all.