Search code examples
amazon-web-servicesload-balancingamazon-lightsail

how to redirect based on domains to aws lightsail instances


possible solution

I need to scale an application, each client has its own instance (api) of aws lightsail that delivers ssl with its respective domain, aws will only deliver 4 public ipv4, one of the solutions that occurred to me is to have a kind of network balancer, which in this case would only redirect to the correct server based on the private ipv4 address of each client instance.

This is possible? Is there a better solution?

I saw that dns zones can be created but they also need to be linked to public and not private ipv4, using public ipv6 is not an option due to the country from which requests are made from the SPA, there is no full ipv6 addressing yet.

I also did not see that the aws lightsail instances are granted public dns to access them from the internet


Solution

  • Yes you can do this by running a reverse proxy server like Nginx on the public facing server, and configure it to proxy requests to the specific Lightsail instances based on the domain name in the request.

    If you were using EC2 servers instead of Lightsail you could do this with an AWS Application Load Balancer, but Lightsail load balancer's don't appear to support any sort of advanced routing configuration.