Need help and advise : Stuck in deploying ALB to multiple port and ec2


Hi there, I have deployed 4 ec2 running docker. One application running in docker serve multiple port almost 7 ports (including web and service ports together). (web)Ports are 9100, 8100 (service)Port are 8000, These 3 ports are important to do load balance I was able to create an ALB by creating 2 target group (testing purpose, just using 2 out of 4 ec2). Each target group created based on what ports are running in each ec2. so 1 target group for 1 ec2 (7 ports) and there other also the same. total are 14 ports exposed to ALB. i found out in health check bar. only showing 1 port health (9100) which is port for web console login, the rest are unhealthy. some error showing 404, 403. and if i go to http://<alb url>. the page keeps asking for login and password. (suspect looping cause two ec2 running the same port.). How to solve this one. Thank you

2 Answers

It seems like there are a few issues occurring here:

You have multiple ports exposed from each EC2 instance, but only the health check port (9100) is showing as healthy. Health checks need to be configured separately for each exposed port.

By placing the same EC2 instances in multiple target groups, the application routing is getting confused and causing login loops. Each instance should only be registered to one target group.

Using separate target groups per ALB is a good approach. But each target group needs its own set of EC2 instances.

To resolve this, I would recommend:

Create a separate target group for each exposed port Configure health checks appropriately for each target group Register unique EC2 instances to each target group Use listener rules to route to the correct target group based on port Consider using Application Load Balancer path-based routing if possible instead of separate target groups This will ensure each port/application route is load balanced independently without conflicts.

profile picture
answered 24 days ago

Thank you for the feedback. For testing, focused on 1 ec2. I have created multiple target group. specifically each target group for specific path@exposed port. So now I able to login with no issue. Next challenge were, how to route specific route if i go to example http:<alb url>/<something>. in this case, all other than / , it will return 302. the "/ " sitting at the bottom of the rule, default rule number. it is related how to assign rule number@weigh? can you advise on this.Thank you

answered 23 days 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.

Guidelines for Answering Questions