Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS auto scaling targets in target groups for Network Load Balancers

Recently started using Network Load Balancer which listens on port 80 and forwards traffic to my target group. My autoscaling group is configured to add any new targets to this target group.

However, my application on the target EC2 instances runs on port 8001, not 80. So my targets should register under port 8001 in the target group. The auto-scaling configuration doesn't seem to support that. All new instances created by auto scaling are added as targets with port 80 and there is no way to auto specify which port that should be used instead (8001 for me).

Any ideas how to implement this?

like image 518
DancingJohn Avatar asked Nov 19 '25 20:11

DancingJohn


2 Answers

The port definition in the target group is the port definition you're looking for. The port in the target group is the port on which the targets receive traffic. The port on the listener is the port on which the load balancer listens for requests.

So you should set port 80 on the listener and port 8001 on the target group.

like image 116
kichik Avatar answered Nov 21 '25 08:11

kichik


What kind of application are you using (web server, application server, ...)? Maybe ALB would be more suitable for you as it works on layer 7 of OSI model, therefore it is able to proccess HTTP headers, for example.

Back to your question; To be able to forward traffic to your EC2 instances, that runs application on port 8001, you have to set port on your target group to 8001. Auto-scaling group knows nothing about what application is running on EC2 it provisions, nor about ports that are used by that application.

So the final flow is like:

LB listens on port 80 and forwards traffic to target group on port 8001. This target group then sends traffic to its targets (your EC2 instances) on port 8001.

enter image description here

like image 21
jpact Avatar answered Nov 21 '25 10:11

jpact



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!