I have three instances on aws. one for nginx which the front-end server, and two backend nodejs intstances.
Im trying to set up the nginx server to upstream to these node.js instances:
upstream node_servers {
server private_ip:8124 weight=10 max_fails=3; // node server 1 private_ip:port
server private_ip:8124 weight=10 max_fails=3; // node server 2 private_ip:port
}
server {
listen private_ip:80; // nginx server private ip:port
root /home/ubuntu/project/;
server_name public_ip.eu-west-1.compute.amazonaws.com; // nginx public DNS
location / {
try_files $uri $uri/ /index.html;
proxy_pass http://node_servers/;
}
}
on my node 1 server, node 2 server instance app.js code:
app.listen(8124, "127.0.0.1");
console.log("listening on 8124");
I go to the nginx server public domain name, and nothing really happens, its just loads forever sending request.....
In your node code, you are listening on the loopback interface on 127.0.0.1 (requests from localhost only):
app.listen(8124, "127.0.0.1");
You have to listen on your specific private IP or 0.0.0.0:
app.listen(8124, "0.0.0.0");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.