Site redirection not working

0

Hello, I have a web site set up in AWS ECS containers using CloudFront and ALB for traffic with URL mydomain.com which is up and running. However, the way another domain www.mydomain.com is currently setup for redirecting to mydomain.com is as an empty S3 bucket to redirect to mydomain.com but when I hit www.mydomain.com in the browser I get: "Error. Failed to contact origin". Both domains have CloudFront distributions each and in Route 53 each has an A record to direct to its own CloudFront distribution.

Can Anyone tell me where the configuration is going wrong? Many thanks in advance.

2 Answers
0

Hi,

Setting up APEX to www and viceversa redirection with Cloudfront may seem a trivial task but it is far from it in AWS!

In my experience, rather than creating a hack with an empty S3 bucket which redirects to the target origin, I would rather setup a CloudFront function that handles the redirection: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/example-function-redirect-url.html.

The 2 possible approaches are explained here too: https://aws.amazon.com/premiumsupport/knowledge-center/cloudfront-redirect-domain/

Hope it clarifies

profile picture
EXPERT
answered a year ago
0

Make sure your Security group on your ALB for www.mydomain.com allows access from cloudfront. Also ensure that the ECS container's SG has access from the same ALB in question also.

Ensure your ALB rules are setup and send requests to the containers. If using custom headers for permission, ensure the correct HTTP Headers are on your alb rules also

profile picture
EXPERT
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