Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create my own error page for Amazon S3

Tags:

amazon-s3

I was wondering if it's possible to create my own error pages for my S3 buckets. I've got CloudFront enabled and I am using my own CNAME to assign the S3 to a subdomain for my website. This helps me create tidy links that reference my domain name.

When someone tries to access a file that has perhaps been deleted or the link isn't quite correct, they get the XML S3 error page which is ugly and not very helpful to the user.

Is there a way to override these error pages so I can display a helpful HTML page instead?

like image 677
thisisready Avatar asked May 02 '11 16:05

thisisready


People also ask

How do you implement a custom error page?

Steps for Custom Error PageSet <customErrors> setting in Web. Config file of the application. Pass defaultRedirect and mode attributes in <customErrors>. If you want to set your application level exception should redirect to your custom error page, you can do this by going to global.

Can static websites created with Amazon S3 can be interactive?

Amazon S3 does not support server-side scripting, but AWS has other resources for hosting dynamic websites. To learn more about website hosting on AWS, see Web Hosting . You can use the AWS Amplify Console to host a single-page web app.


1 Answers

If you configure your bucket as a 'website', you can create custom error pages.

For more details see the Amazon announcement of this feature and the AWS developer guide.

There are however some caveats with this approach, a major one being that your objects need to be publicly available.

It also works with Cloudfront, but the same public access limitations apply. See https://forums.aws.amazon.com/ann.jspa?annID=921.

If you want, you can try these out right away by configuring your Amazon S3 bucket as a website and making the new Amazon S3 website endpoint a custom origin for your CloudFront distribution. A few notes when you do this. First, you must set your custom origin protocol policy to “http-only.” Second, you’ll need to use a tool that supports CloudFront’s custom origin feature – the AWS Management Console does not at this point offer this feature. Finally, note that when you use Amazon S3’s static website feature, all the content in your S3 bucket must be publicly accessible, so you cannot use CloudFront’s private content feature with that bucket. If you would like to use private content with S3, you need to use the S3 REST endpoint (e.g., s3.amazonaws.com).

like image 172
Geoff Appleford Avatar answered Sep 30 '22 12:09

Geoff Appleford