0
votes

I have a EC2 cluster with just one EC2 instance, where two services are running:

  • api1, listening at port 8080

  • api2, listening at port 9090

If I make requests against EC2 instance and those ports, both APIs work fine.

Now, I want to create a load balancer so I can make requests against http://{load_balancer_ip}/api1 and http://{load_balancer_ip}/api2, but I'm not able to.

I have created two target groups, both with just one instance (the only one I have)

  1. TargetGroup1: Port 8080 and the EC2 instance registered on port 8080
  2. TargetGroup2: Port 9090 and the EC2 instance registered on port 9090

Then, I have created a load balancer with one listener on port 80 and these two path rules:

  • When /api1, forward to TargetGroup1
  • When /api2, forward to TargetGroup2

When I make requests against http://{load_balancer_ip}/api1 or http://{load_balancer_ip}/api2 nothing happens; I don't get any response.

What am I missing?

1
What are the security groups you attached to the EC2 instance and to the load balancer ? - Sébastien Stormacq
1: Load Balancer will provide you DNS, not IP. 2: There is a Listener Rule, Where you need to provide the path followed by the target group. Have you Checked with this? - Sunil Valmiki

1 Answers

0
votes

Ok, I found what's happening thanks to this question's first comment:

AWS Application Load Balancer (ALB) path based routing not functioning as expected

Load balancer is not rewriting the URL and my APIs are listening at /, but load balancer is redirecting all the path /api1.

Solved!

(I couldn't mark it as duplicated because question above does not have any accepted answer)