1

I'm using AWS and trying to remap a huge application to small parts - in summary: I'm transforming a monolitic application to a micro-service based one.

So I want to use a public facing loadbalancer where I can route some paths to other enviroments.

For example:

domain.com/service1 to another load balanced application in Elastic Beanstalk and

domain.com/service2 to a different load balanced application in Elastic Beanstalk too.

I was able to connect Application Load Balancer to another EC2 instance. But I tried without success to connect it to another Load Balancer created by Elastic Beanstalk.

Does anyone have some ideas in how to accomplish this?

Tulio Faria
  • 213
  • 2
  • 5

1 Answers1

0

You're not going to find support for this natively with ELB and Elastic Beanstalk's feature-set.

I would suggest path-based forwarding using HAProxy to send traffic to your Elastic Beanstalk application(s). You'll want to run this on a pair of EC2 instances sitting behind a simple Classic ELB running a health check against HAProxy itself, for the sake of high-availability.

Here's a general example with HAProxy:

# match incoming request based on path in url
acl service1 path_beg /service1
acl service2 path_beg /service2

# send matched request to a specific backend
use_backend service1 if service1
use_backend service2 if service2

# define the target backends (Elastic Beanstalk LB DNS, likely)
backend service1 :80
  option httpchk /haproxy_health_check
  server service-1 service1.aws.mybeanstalklb.com:80 

backend service2 :80
  option httpchk /haproxy_health_check
  server service-2 service2.aws.mybeanstalklb.com:80 

If you're not interested in running this on your own on EC2, you can explore injecting this config into an HAProxy docker image and running the container on EC2 Container Service.