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.

Abdel
已提問 1 年前檢視次數 308 次
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
專家
已回答 1 年前
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
專家
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南