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)
TargetGroup1
: Port 8080 and the EC2 instance registered on port 8080TargetGroup2
: Port 9090 and the EC2 instance registered on port 9090Then, I have created a load balancer with one listener on port 80 and these two path rules:
/api1
, forward to TargetGroup1
/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?
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)