Skip to content

How to properly set up load balancer as the main load balancer and one for subpath in LightSail

0

I've set up kubernetes cluster using this link. I have also setup the Load Balancers. For my usecase I have two load balancers, one supporting the main website (www.site.com) backed by Spring boot containers and the other load balancer serves as the images (www.site.com/images/*). I have verified that both are working fine with http calls. Now the next step for me is to get the website (www.site.com) fully functional. E.g. when someone hits the www.site.com, it serves the images from the image load balancer and the rest from the main load balancer. I'm not sure how to properly set up that. It would have been a lot easier if I could set up ingress in the kubernetes cluster and it can route everything based on the paths. But the documentation doesn't mention how to set up the nginx ingress. That's why I created these two load balancers to support my usecase. Now I just need to get some guidance on how to configure these two load balancers with the domain name.

asked 2 years ago271 views

1 Answer
0

To set up your Lightsail load balancers to work together for your main website and image subpath, you'll need to take a few steps:

  1. Main Load Balancer Setup:

    • Configure your main load balancer to handle traffic for www.site.com.
    • Attach your Spring boot container instances to this load balancer.
  2. Image Load Balancer Setup:

    • Configure your second load balancer to handle traffic for www.site.com/images/*.
    • Attach the instances serving your images to this load balancer.
  3. SSL/TLS Certificates:

    • Create SSL/TLS certificates for your domain (www.site.com) and attach them to both load balancers to enable HTTPS.
  4. DNS Configuration:

    • Set up your domain's DNS to point www.site.com to the main load balancer's IP address.
  5. Proxy Configuration:

    • Since Lightsail load balancers don't support path-based routing directly, you'll need to set up a reverse proxy (like Nginx) on your main application servers.
    • Configure this proxy to route requests for /images/* to the image load balancer.
  6. Application Logic:

This setup will allow your main load balancer to handle most traffic, while requests for images will be internally routed to your image load balancer.

Remember to enable HTTPS redirection on both load balancers for better security. Also, keep in mind that you're limited to 5 load balancers per AWS region in Lightsail.

While this solution works, it's more complex than using Kubernetes Ingress. If possible, consider exploring options to set up Ingress in your Kubernetes cluster for more flexible routing capabilities.
Sources
CreateLoadBalancer - Amazon Lightsail
Redirect HTTP to HTTPS for Lightsail load balancers - Amazon Lightsail
Distribute web traffic with a Lightsail load balancer - Amazon Lightsail
SSL/TLS certificates in Lightsail - Amazon Lightsail

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.