Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS S3 bucket "404 Not Found"

At the moment I'm hosting a bundled Angular-2 App in an AWS S3 bucket, so it only contains .html and .js files.

The absolute path http://example.com/ does work but if I switch to any links, such as http://example.com/testsite it returns 404 error as below:

404 Not Found
Code: NoSuchKey
Message: The specified key does not exist.
Key: voucher
RequestId: 7A08F32C18D3C6D3
HostId: 6jTd5D5QDU+AP4vo+uRcHHVT5WeRAKjoPeqVb39xoKZZSvWWz/9TsNp41TbuKXmtpYbLZJiyqwE=

I already tried another bucket policy and I set every file to public, but it won't work for me.
Anyone has a solution? Please help.

like image 776
sHamann Avatar asked Jun 06 '17 06:06

sHamann


People also ask

How do I fix AWS 404 error?

If the requested object was available in the S3 bucket for some time and you receive a 404 NoSuchKey error again, then check the following: Confirm that the request matches the object name exactly, including the capitalization of the object name. Requests for S3 objects are case sensitive.

Why is my S3 bucket Access Denied?

The "403 Access Denied" error can occur due to the following reasons: Your AWS Identity and Access Management (IAM) user or role doesn't have permissions for both s3:GetBucketPolicy and s3:PutBucketPolicy. The bucket policy denies your IAM identity permission for s3:GetBucketPolicy and s3:PutBucketPolicy.

Which S3 error code does not have a corresponding HTTP 404 status code?

Which S3 error code does not have a corresponding HTTP 404 Status code? You are working with the S3 API and receive an error message: 409 Conflict.


2 Answers

In my case, I had to specify index.html in both Index document and Error document on S3 Static website hosting properties.

like image 57
Zohab Ali Avatar answered Sep 21 '22 16:09

Zohab Ali


Your bucket policy Resource property needs to contain, note the /*:

"Resource":["arn:aws:s3:::bucketname/*"]

You also need to set the error document to be your index.html

like image 34
David Findlay Avatar answered Sep 22 '22 16:09

David Findlay