Static website hosted in AWS S3 and CloudFront - amazon-web-services

I have hosted Static website in AWS S3 and CloudFront. website contexts is multiple pages. I do have a problem with distribution. For example i do have have domain example.cloudfront.net when i am accessing it from this domain no problem i can go there and click on every page that i have lets say i am in a main page and i click about and domain automatically becomes example.cloudfront.net/about/ when i cope this path and paste it in a new page it gives
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
not sure what is the issue. Is there anyone who could help?
Thank you
Tried to give permission to access multiple folder inside of the bucket individually and also for whole bucket. Tried to recreate everything from scratch if I missed something but nothing helps. We can not make bucket public FYI

You need to set a rule for 403 Forbidden in your CloudFront configuration as posted here: Receive AccessDenied when trying to access a reload or refresh or one in a new tab in angular 5

Related

Access Denied when accessing a page in a CloudFront Amazon S3 static website

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
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.
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.

AWS CloudFront not able to point to specific url subpage

I am using reactJS to develop our website, which I uploaded to S3 bucket with both index and error documents pointing to "index.html".
If I use the s3 bucket's url, say http://assets.s3-website-us-west-2.amazonaws.com", I get served my index.html. So far, so good. If I then go to specific subpage by deliberately appending /merchant, it goes there to without any problem although there is no folder called /merchant in my s3 bucket.
However, if I now attach this S3 bucket to my CloudFront distribution, and I try to directly address "https://blah.cloudfront.net/merchant", it responds with "access denied" because it could not find the subfolder /merchant in s3 bucket.
How do people get around this issue with CloudFront? I have so many virtual subpages that don't map to physical folders.
Thank you!
I have the answer.
In the cloudfront, set a custom error response like this

CloudFront No Longer works after modifying S3 bucket

I originally created an S3 bucket with a cloudfont to display the html code in the bucket at the publicly hosted domain hosted. I deleted the contents of the S3 bucket and uploaded new files. The endpoint for the S3 bucket displays fine in the web. The hosted url no longer works, I get an 404 error.
Failed to load resource: the server responded with a status of 404 ()
Could you please provide more details of your CloudFront distribution settings? I wrote this article explaining how Cloudfront and S3 works and how you can deploy React applications step by step! It might be useful for you.
Please have a look at: Medium - How to deploy single page applications to Cloudfront
I discovered my error. Instead of using the drop down menu for the orgin link I used the endpoint of the bucket. It works now.

Accessing static website in S3 bucket through Cloudflare with Full SSL

I have been trawling forums, blog posts, technical places and I've also got in touch with Cloudflare support and I'm no further forward with this. Cloudflare says that AWS is not accepting the host headers for mine.mydomain.com and returning 403.
I have an S3 bucket setup called mine.mydomain.com, with static website hosting turned on. It gives me an AWS URL to use which works fine to browse the site and any pages within it.
I have created a CNAME record on Cloudflare for mine to point to the AWS URL of the bucket. However when I try to browse to the site using mine.mydomain.com I get Access Denied errors.
What I have been told is that because we're using full SSL I need to create an empty bucket called mine-abc (it could actually be anything I just used that name - just as long as it doesn't have dots in it) and map the CNAME record in Cloudflare to mine-abc.s3.amazonaws.com. When I do that I still get an Access Denied error for mine.mydomain.com. However if I go to mine.mydomain.com/index.html it works. It's also the same if I go to the root of URL I get Access Denied (ie. mine.mydomain.com/issues) but if I go to a page (ie. mine.mydomain.com/issues/index.html) it again works.
So I'm a little stumped.
Configuration for the mine.mydomain.com bucket is:
Public Access Settings - all False
Access Control List - Default
Bucket Policy - effectively Allow "arn:aws:s3:::mine.mydomain.com" (and `"mine.mydomain.com/*"`)
CORS Configuration - Allow GET and HEAD for `.mydomain.com and mydomain.com
Any help gratefully appreciated.

Amazon web hosting URL not changing

Just hosted a website on amazon aws in a s3 bucket. When I move around in the website the URL doesn't change, even if the link redirect on a page with a different path.
I read around that it has something to do with iframes, even though I'm not sure what they are.
Regardless, I'm just wondering whether it's possible with the aws s3 to make so that by moving around in the website, the URL gets updated as well.
For testing purposes, this is the link to the website, and to go to another part of the website, just scroll down and click on the website image.
Thank you!
I've manage to find out how to connect the web hosting s3 bucket to the freenom free domain provider.
The s3 bucket needs to have the same name as your domain + the "www". In my example my domain was paolo-caponeri.ga, the bucket needs to be www.paolo-caponeri.ga
Then in the freenom domains manager you need to go the name servers section, select the "Use default nameservers" and then press "save"
Finally you need to go to the freenom DNS manager and add a new CNAME record with "www" on the left and the full link to the s3 bucket provided in the amazon s3 properties on the right; in my case it was "www.paolo-caponeri.ga.s3-website.eu-central-1.amazonaws.com"
And that's it, after a while you should be able to connect to your website without having the URL being masked.
(thank you to Frederic Henri, who got me much closer to the answer!)
NB: I have no experience with freenom so those are more advices than a proven solution.
It seems freenom is doing frame forwarding and you would need instead a "A" / "CNAME" referral.
Your site runs fine if you go to http://testpages.paolo.com.s3-website.eu-central-1.amazonaws.com/ and as such bypass the freenom redirection.
A quick search on freenom seems it could be possible: https://my.freenom.com/knowledgebase.php?action=displayarticle&id=4