How can Nodejs be deployed to Aliyun and be called on the public network?

 ECSiis
iis127.0.0.1   ip
node
80:

var http = require("http");
//
var server = http.createServer(function(req,res){
    if(req.url == "/"){
        //
        res.writeHead(200,{"Content-Type":"text/html;charset=UTF8"});
        res.end("");
    }else{
        res.writeHead(404,{"Content-Type":"text/html;charset=UTF8"});
        res.end("");
    }
});
server.listen(80,"127.0.0.1");   

then run the js file through cmd. At this time, if you open 127.0.0.1 on the server, you can normally display the success message on the web page, but on the external network through http://xx.xxx.xx.xx, you will display the page with the wrong link to the website. Look at F12 and see that the request has not received any server data.
what is the reason for this, and what can be done to enable the public network to call the background data of node? Thank you first

Nov.08,2021

as mentioned above, we can server.listen (80, '0.0.0.0')
, but generally we don't do this, because the server that comes with node is only basic server, that lacks some advanced functions, such as load balancing, access control, etc., so we will server.listen (8080,' 127.0.0.1') run locally, and then expose Nginx to the public network. Nginx reverse proxy local node server


server.listen(80,"0.0.0.0")

https://blog.csdn.net/zhy4212. gives you a link

when we wrote the first program, we found that it could not be accessed on the external network. At this time, we need to open the port. For example, our port is 8888 and we need

/ sbin/iptables-I INPUT-p tcp-- dport 8888-j ACCEPT-sharp opens port 8888

< H2 > I am centos 7, so I ran service network restart, successfully and accessed < / H2 > on the public network.

author: KinGofWorLd_v587
Source: CSDN
original text: https://blog.csdn.net/zhy4212.
copyright notice: this article is the original article of the blogger, please attach a link to the blog article to reprint it!

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-7b07e7-29399.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-7b07e7-29399.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?