Reputation: 275
I've deployed an Angular static website to Amazon S3 and used Cloudfront for it. When I'am accessing the default page myurl.com/
everything works fine and I can navigate through pages. But if I go to a certain page directly myurl.com/posts
for example I get an access denied with cloudfront. If I do it with the amazon s3 website endpoint I get a 404 response.
S3
Cloudfront
Upvotes: 1
Views: 2931
Reputation: 1960
in my case, I set a default root object and things worked, after waiting for about 10 minutes so the setting changes sync. http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DefaultRootObject.html
To specify a default root object using the CloudFront console:
Sign in to the AWS Management Console and open the Amazon CloudFront console at https://console.aws.amazon.com/cloudfront/.
In the list of distributions in the top pane, select the distribution to update.
In the Distribution Details pane, on the General tab, click Edit.
In the Edit Distribution dialog box, in the Default Root Object field, enter the file name of the default root object.
Enter only the object name, for example, index.html. Do not add a / before the object name.
To save your changes, click Yes, Edit.
Upvotes: 1
Reputation: 35258
The documentation states that a 403 will be returned in CloudFront for a number of reasons. One of the resolutions is The requested objects must exist in the bucket.
.
As you're trying to access an object that does not exist CloudFront may be turning this into the 403 that you are receiving.
You should attempt accessing a key that does exist only, and configure your s3 endpoint to use an error document for times when the page does not exist.
Upvotes: 1