1

I have a requirement to have an AWS load balancer that listens on a non standard port and routes connections to different ports on the same EC2 instance(s), treating each port as a unique target. The Ec2 instances would be depoloed using Auto Scale Groups.

Example the load balancer listens on port 300 and routes to ports 3001 and 3002 on EC2 instances. While this is a good candidate for usage with containers on ECS, I cannot use containers due to other constraints.

The problem is similar to what is discussed here: AWS ELB when target (backend) applications runs on multiple ports of the same EC2

except that here the use case is for a non standard port and the solution discussed in the above post to register each port as a separate target will not work with auto scaling group. This is because when an ASG brings up instances it cannot register instances in the target groups with multiple ports.

Is there anyway to achieve this using the standard load balancer + target group combination or will this require custom implemenation within the EC2 instance to perform the internal routing?

Tried a combination of single Load Balancer + multiple Auto Scale Groups and\or multiple Target Groups, but all of these require more than one listener on the Load Balancer itself. Usage of ALB is not an option since the traffic is not HTTP(s).

fortytwo
  • 11
  • 1
  • You actually can register the same target with multiple ports in ASG. You only need to associate your ASG with multiple target groups (I did this in the past when a client had 5 containers on the server with each of those using some non-standard ports and wanted to add autoscaling) – Caldazar May 24 '23 at 20:47
  • This is true, however in my case I can have only one listener on the NLB and hence that listener can only be connected to a single target group. This mean even though the ASG can point to multiple target groups, they cannot get traffic from the NLB. – fortytwo May 25 '23 at 03:50

0 Answers0