Search code examples
amazon-web-servicesamazon-ec2aws-application-load-balancer

AWS Load Balancer not working correctly as it is not giving the website view as the EC2 ip and port gives


I wanted to configure two EC2 instances running ExpressJS api server on port 8000 to AWS load balancer. The Load Balancer DNS gives error "crbug/1173575, non-JS module files deprecated. (anonymous) @ (index):6583", while the health checks are fine. The EC2 instance's ip and port gives the actual result.

I created Target Group, chose target type as 'instance', on protocol set it to 'http' and port to '8000' Used Health check on the server fetching data from '/data?warehouse=Warehouse%201' Then on the register target page selected both the Available instance and port as '8000'

enter image description here

Then on creating the Load Balancer, chose Application load Balancer, scheme to 'internet-facing' , IP Address type to "IPv4", kept the security groups same as EC2 instances. On Listeners and routing part, chose listener protocol to 'HTTP' and set port to '8000' then Forward to 'target group I created'

Created the Load Balancer in this way.

enter image description here

Now the health check is saying healthy but the DNS is not routing me to the EC2 website page that I get from the EC2 IP and port 8000. It gives error "crbug/1173575, non-JS module files deprecated. (anonymous) @ (index):6583" The actual result can be viewed here: http://18.140.239.237:8000/data?warehouse=Warehouse%201 The Load Balancer DNS: http://backendloadbalancer-1996574208.ap-southeast-1.elb.amazonaws.com/data?warehouse=Warehouse%201


Solution

  • Your listener rule needs to listen on port 80 and forward to the target group on port 8000.

    You are instead listening on port 8000 and forwarding on port 8000 too, because accessing to http://backendloadbalancer-1996574208.ap-southeast-1.elb.amazonaws.com:8000/data?warehouse=Warehouse%201 returns the correct response.