Architecture for request forwarding to multiple applications within same domain

0

I have multiple websites hosted in different environments such as S3 static HTML, self-hosted WordPress on Amazon Lightsail, application on Elastic Beanstalk, and external sites (e.g. Wordpress.com/Wix/Webflow).

I want to unify all those applications under a single domain name, let's say www.example.com. The routing are using a request path and also a user-agent.

The scheme looks like below

image

If the request, for example, is https://www.example.com/a, it will be forwarded (not redirected) to Site A. If the request is https://www.example.com/d and accessed with mobile devices, it will be forwarded to Site B, but if accessed with desktop devices, it will be forwarded to Site C. When the request is https://www.example.com/sitemap.xml it will be forwarded to a public file stored in S3.

One solution that I have in my mind is using ALB with Routing. But ALB only allows 3 kinds of target groups, as far as I know: 1) instance, 2) IP, and 3) Lambda. So I am thinking of targeting Lambda which serves as a proxy to the applications. Something like below.

image2

I am wondering if there are better solutions.

질문됨 2년 전554회 조회
1개 답변
1
수락된 답변

You can do this with a CloudFront distribution with multiple origins and behaviors. You will use a NoCache policy so all requests are forwarded to your origins except maybe your S3 objects. You will need to use Lambda@Edge or CloudFront Functions to handle the user-agent requirement.

Take a look at Accelerate your content using Amazon CloudFront

profile pictureAWS
전문가
kentrad
답변함 2년 전
  • Hi @kentrad, thanks a lot for the comment. The solution looks great! But I am wondering, do you think my initial ALB solution could work? And also what are the trade-off between this one and the ALB solutions?

  • @Petrabarus. Your Solution has more moving parts that you need to take care of is the first point. An ALB involves more costs compared to CloudFront. Using Lambdas as a Proxy is one of the Lambda Anti Patterns. And you have to pay for the wait-time till your Response arrives in your Lambda Function.

    Hope this helps

  • @kentrad that makes sense totally! thanks a lot for the answer. really appreciate the customer obsessions.

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

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

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

관련 콘텐츠