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
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.
I am wondering if there are better solutions.
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.