How to stop CloudFront from redirecting to S3 bucket.

0

I have an Amplify Hosting frontend that uses a rewrite redirect (200) to redirect to an S3 bucket. That worked out fine but then I created a CloudFront distribution and since then, the rewrite gives a timeout after 30 seconds serving a 504 error. That is why I disabled and then deleted the CloudFront distribution. However the timeout and 504 error (coming from CloudFront) is still there. Any ideas how to fully remove this CloudFront forwarding or do I have to delete the bucket/frontend?

2 Answers
0

Hi there,I understand you want to delete CloudFront distribution because of 504 error you keep on getting.Please correct me if I misunderstood.

To further understand the issue when getting a 504 error or timeout it indicates that when Cloudfront forwarded a request to the origin ,one of the following might have happened: [1]The origin returned an HTTP 504 status code to CloudFront. [2]The origin didn’t respond before the request expired.

Cloudfront will return an HTTP 504 status code if traffic is blocked to the origin by a firewall or security group if the origin isn’t accessible on the internet.Check for these issues first.If access isn’t the problem with your CloudFront check application delays and server timeouts, using link [3] to help you identify and fix the issue.I would also recommend changing the timeout value to 60 seconds.

However if you no longer want to use a CloudFront distribution, you can delete it by using the CloudFront console or by using the CloudFront API.Please make sure that you have disabled distribution before deleting it.For more instructions on how to delete CloudFront distribution ,use this link for the console [4] and this link [5] for the CloudFront API

I hope the above information is helpful.

Reference

[3]https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/http-504-gateway-timeout.html#http-504-gateway-timeout-configure-firewall [4]https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/HowToDeleteDistribution.html [5]https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_DeleteDistribution.html

Karabo
answered 2 years ago
0

Given this issue is actually due to the internal DNS propagation of the S3 bucket name that occurs when you set up the bucket in S3, then it can be possible to avoid this issue by configuring a public web site in S3 prior to configuring the Cloudfront distro, and per the doco, configure the S3 public web name as the cloudfront origin instead of the s3 bucketname.

Reference: AWS official setup guide

AWS
answered 9 months 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.

Guidelines for Answering Questions