36

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.

Subtubes
  • 15,851
  • 22
  • 70
  • 105
  • 3
    Yes, use ALB instead of ELB classic. ALB gives you the flexibility to use extra ports on the backend services. – Sam Feb 24 '17 at 11:11

2 Answers2

37

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

Amit
  • 30,756
  • 6
  • 57
  • 88
  • Hi, Thanks much for above clear explanation, but for me it's not worked. My configuration is, installed Apache Solr service in Private EC2 and trying to configure Apache Solr service with internal ALB(not internet-facing). Only when i append port in ELB URL then only able to access. internal-solr-elb-714176139.us-west-2.elb.amazonaws.com:8983/… as you know i need to access ELB without port to work with Route53 – Sreenivas Reddy Jul 07 '21 at 09:19
23

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.

Mark B
  • 183,023
  • 24
  • 297
  • 295
  • Hi @Mark - can you please let me know what rules should I write in ALB to forward to PORT 3000? My React app is running on PORT 80, where as NODE JS API is running on PORT 3000. I want to run NODE JS API from my domain like - https://www dot mydomain dot com/api:3000 – Sachin Vairagi Aug 07 '20 at 05:56
  • 2
    @SachinVairagi please don't add your question to other people's questions like this. Please post a separate question including what you have tried, and what issues you are encountering. – Mark B Aug 07 '20 at 14:33