0
我有一个Amazon EC2服务器,我已经配置了节点js服务器,但它不能从外部通过公共dns访问,但可以通过同一实例(本地主机)访问。任何帮助都感激不尽。Node.js不能从外部IP访问
服务器代码:
var my_http = require("http");
my_http.createServer(function(request,response){
console.log("Request Recieved : "+request.url);
response.writeHeader(200, {"Content-Type": "text/plain"});
response.end("Server is UP \n");
}).listen(3000, "0.0.0.0");
console.log("Server is Running on Port 3000");
netstat的输出
netstat -tupln | grep :3000
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 11706/node
卷曲输出
curl http://127.0.0.1:3000 => Server is UP
curl http://localhost:3000 => Server is UP
curl http://{PRIVATE_IP}:3000 => Server is UP
curl http://{PUBLIC_DNS}:3000 => curl: (52) Empty reply from server
您是否在安全组中打开了端口3000? –
是,端口80,22,3000,3001是开放的 – Shashi