Search code examples
htmlnode.jsamazon-web-servicesamazon-ec2

How to send html traffic from a html file to a Load Balancer in AWS?


I made an architecture in AWS like this : 2 AZ, each AZ has one public subnet and 3 private ones. The three subnets are for: web servers (html and css files),app servers (node.js file) and a database. I made load balancers and auto scaling. The server works fine except that i have a page that needs to send data (forum) to the node.js server to put it in the database, so i put it like this my html file: < form action="http:///submit" method="post"> and this is how my server app.js is accepting the data: app.post('/submit', (req, res) => (on port 3000) in the SG of the LB i made the traffic type http with the source being the web servers' SG my problem is when i try to submit the forum it always say : LB DNS Name took too long to respond Did i do something wrong ?

I tried changing the inbound and outbound rules but it didn't work. I'm thinking maybe this is wrong: form action="http:///submit" method="post"...


Solution

  • The URL should either be absolute or relative. In your case, you have given the protocol and /submit. If the domain name and protocol remains same, set the action to action=/submit. Since you want this submit request to go to nodejs, create a higher priority listener rule on your ALB (I am assuming that you are using an application load balancer) to eoute the path /submit to the target group of nodeJs