Skip to content

AWS CloudFront distribution returning 403s when attempting to access any other page but root.

0

I have an AWS S3 bucket configured as a website endpoint that is sat behind a CloudFront distribution. I can access the root page just fine. When I attempt to access other pages on my website (e.g. /about or /contact) CloudFront returns a 403. My S3 bucket access control policy is below:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::no-name-games.com/*"
        }
    ]
}

Please let me know what other information I need to provide.

asked 2 years ago343 views
3 Answers
2

Hello.

CloudFront passes the accessed URL as is to the origin.
For example, when you access CloudFront as shown below, the folder "/about" is accessed, but no files are retrieved.

https://cloudfront.com/about

To retrieve a file, you need to include the file name at the end of the URL.
For example, index.html in /about needs to be accessed as follows.

https://cloudfront.com/about/index.html

Also, if you want to omit index.html in a subfolder from the URL, you need to configure CloudFront Functions as described in the document below.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/example-function-add-index.html

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago
EXPERT
reviewed 2 years ago
2

Hi,

You may also need to add s3:listObject to allow CloudFront to work properly.

See some examples of such auth on this page: https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-policies-s3.html

Best,

Didier

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago
EXPERT
reviewed 2 years ago
  • The permission for listing current object versions in the bucket is s3:ListBucket.

1

Hello,

You are hosting a website through S3. The root page is opened with no issue but when you are exploring other pages then you are facing the issues.

It might be issue with your code. Your about, Contact page files may not be linked with index.html file. So once go through the website Code.

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago
EXPERT
reviewed 2 years ago
EXPERT
reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.