I bought an Aliyun ecs host, but why can"t I use the original node to listen to a port that cannot be accessed through the public network, but can access it through the public network with express monitoring? what core sentences does express have to solve this problem?
NODE native:
var http = require("http");
var server = http.createServer(function(req,res){
res.writeHead(200,{"Content-type":"text/html;charset=UTF-8"});
res.end("ok");
});
server.listen(3000);
Express:
var express = require("express");
var app = express();
app.get("/",function(req,res){
res.writeHead(200,{"Content-type":"text/html;charset=UTF-8"});
res.end("ok");
});
app.listen(3000);
the above statement is also listening to port 3000.
access to port 3000 via public network ip:3000 is enabled after Aliyun"s backend security settings are enabled. Express can get data, but node can"t write it itself.