CloudFront is Returning 504 Errors when Redirecting

1

We want to redirect our old domain (website.io) to our new domain (website.com)

We use Route 53 for DNS management of website.io.

After reading some forums, the recommended approach was setting up a static website redirect using S3, then serving up S3 with CloudFront to support https. Otherwise, S3 only redirects http requests over port 80.

SO, the configuration is now:

  1. Route 53: alias A name record pointing website.io a CloudFront formation
  2. CloudFront: origin is pointing at an S3 bucket, and it is using a valid certificate with matching common names
  3. S3: redirecting website.io to website.com

The issue is CloudFront non-deterministically returns a 504 when some visitors view the original site (that should redirect). Visiting the S3 bucket directly is very snappy (new site loads in less than a second), so I find it hard to believe that the site is actually timing out when CloudFront is requesting data, but the nondeterministic nature makes that seem like the most logical reasoning.

Has anyone seen this error happen before? Any suggestions on how to remediate the issue.

2 Answers
0

Hi there!

From the notes, I understand that you are currently getting a CloudFront 504 error after attempting to redirect your old domain to a new one. Please correct me if I am wrong.

Please note that CloudFront will return an HTTP 504 status code if traffic to the origin is blocked by a firewall or security group, or if the origin isn’t accessible on the internet. You can check [1] on how to configure the firewall on your origin server to allow CloudFront traffic. Since you mentioned that “Some visitors” are getting the error, I would suggest that you look for any firewalls or security rules that block traffic from CloudFront edge locations, based on the published IP address range. If your origin uses Elastic Load Balancing, review the ELB security groups and make sure that the security groups allow inbound traffic from CloudFront, check document in link [2].

Check for those issues first. Then, if access isn’t the problem, explore application delays and server timeouts to help you identify and fix the issues. You can check [3] for steps you can take to find performance issues and how to correct them.

I hope you find the above information helpful.

Have a great day ahead!

References:

[1] https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/http-504-gateway-timeout.html#http-504-gateway-timeout-configure-firewall [2] https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-security-groups.html [3] https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/http-504-gateway-timeout.html#http-504-gateway-timeout-slow-application

Letty
answered 2 years ago
0

I'm getting same issue. I think it's something with the CloudFront configuration - tried a number of options with no luck so far.

3 domains in play:

  • CloudFront custom hostname - adds HTTPS (ex: website.io)
  • S3 website endpoint (CloudFront Origin - HTTP only): ex: website.s3-website-us-west-2.amazonaws.com
  • Redirect hostname (ex: website.com)

Tests:

answered a year 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