Reroute traffic from CloudFront distribution to another domain URL

0

Hi,

I need to solve an interesting case related to CloudFront rerouting. Earlier I setup a S3 bucket which is used as a origin in CloudFront and I can fetch the data using this CloudFront Distribution url. Now I want to redirect all my request coming to xyz.cloudfront.net on port 5000 to be routed to abc.non-aws-domain.com. xyz.cloudfront.net:5000/rest-info/doc —> abc.non-aws-domain.com:443/rest-info/doc The problem is I see now that xyz.cloudfront.net:5000 does not exist. I tried to use ALB for this purpose but I see that after creating it and some rules I still see with curl that there is no rerouting. What did I miss? Should I use another solution for this?

Kind regards, Ivan Manzhulin

Ivan M
已提問 3 個月前檢視次數 280 次
2 個答案
1

Hello.

As you know, CloudFront listens on ports 80 and 443, so accessing it on port 5000 will result in an error.
https://repost.aws/knowledge-center/cloudfront-supported-protocols

I think it is possible to route using ALB.
Have you configured the ALB redirect action?
https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html#redirect-actions

For example, if you configure the following settings, when an access occurs at "http://ALBDNS:5000", a redirect will occur to "google.com".
a

profile picture
專家
已回答 3 個月前
  • Thanks, I did almost the same. I used ALB (internet-facing); created target groups, listener on port 5000 and rule to redirect to URL. But I do not see that this is working

  • The reason why I want to use port 5000 is to set up CNAME on this CloudFront and redirect Docker incoming requests (docker pull mostly). And at the same time just CloudFront distribution URL should redirect to S3 bucket objects (this part was done and tested)

0

Thanks, it worked. I forgot to create a custom VPC with public subnets (I was using a default one before).

Ivan M
已回答 3 個月前

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

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

回答問題指南