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개 답변
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
전문가
답변함 일 년 전
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
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인