On one ECS cluster (on the same EC2), I am running two containers:
first container: one API working on :3000/a second container: one gradio UI on port :5000/b
Through an Application Load Balancer, I am connecting them to a website (www.example.com) with an SSL certificate on port 443, so that the https://www.example.com is valid.
However, I have to choose to allocate my listener on port 443 to either one port on the EC2 (either 3000 or 5000).
Is there a way, perhaps using rules, to connect both ports to have: https://www.example.com/a and https://www.example.com/b
Yes, you can use ALB rules to achieve that:
First, you need to create 2 Target groups (A and B for example), one for port 3000 and the second for port 5000.
If you want to use the same domain name and different path, then you would use Path
in the IF
clause of the rule.
If you want https://www.example.com/a
to go to port 3000, your rule would state IF Path is /a Forward to Target group A
If you can have some more additions, like query strings, parameters that will go through the same path, you would set a rule to be IF Path is /a* Forward to Target Group A
And then, do the same for Target group B.