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.

gefragt vor 2 Jahren554 Aufrufe
1 Antwort
1
Akzeptierte Antwort

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
EXPERTE
kentrad
beantwortet vor 2 Jahren
  • 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.

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen