Subtubes
Subtubes

Reputation: 16863

How to forward port in AWS Application load balancer (ALB) port forwarding

Is it possible to have an application running on an EC2 instance and have a load balancer listen on port 80 but proxy it to the instances port 8080?

I cannot seem to get this to work. What setting to I need to change. I am running the cluster behind an application load balancer.

Upvotes: 41

Views: 59888

Answers (3)

aknoerig
aknoerig

Reputation: 31

Yes, it is definitely possible to use the Application Load Balancer (ALB) for port-forwarding. As described in the other posts, you need to define both ends and connect them:

  1. In the ALB listener, set the incoming port (usually 80 for HTTP or 443 for HTTPS)
  2. Create a target group and set the target instance and the port that is served from there (in this case 8080)
  3. Associate the listener with the target group

Also make sure that the security group, which is set for the load balancer, is not blocking any of the incoming or outgoing ports. (This is what caught me and why I added this additional answer.)

Upvotes: 3

Amit
Amit

Reputation: 32376

Adding answer with AWS management snippets .

Add the instance port in the target group, refer below image for it. for example i've added tomcat 8080 port to the target group port/

enter image description here

Make sure that your ELB is internet facing. refer below image of ELB summary , which says that my ELB is internet -facing. and check that your routing is properly added.

enter image description here

Upvotes: 38

Mark B
Mark B

Reputation: 200456

You define the instance port in the Target Group. You need to configure the Target Group to use port 8080. Then point the Application Load Balancer's port 80 listener to the Target Group. The ALB will listen on port 80, and forward requests to port 8080 on the Target Group instances.

Upvotes: 26

Related Questions