我最近得到了node.JS 我一直在看的所有教程告诉我去本地主机查看应用程序,我使用的是端口2000.我明白localhost也是我的ip .. 192.168.0.1:2000,我有调制解调器设置端口转发端口2000,但服务器仍然无法从其他网络访问。请帮忙。那么我怎样才能从其他网络访问我的网站?如何从其他网络访问我的网站?
//app.js
var express = require('express');
var app = express();
var serv = require('http').Server(app);
app.get('/',function(req, res) {
res.sendFile(__dirname + '/client/index.html');
});
app.use('/client',express.static(__dirname + '/client'));
serv.listen(2000);
console.log("Server started.");
错误的论坛,但无论如何。当您尝试从其他网络访问它时,您需要使用您的传出IP,而不是本地。你是?另外,我怀疑你的portforwarding是不正确的。您需要将端口2000转发到承载nodejs程序的机器。不要到192.168.0.1,因为那是你的路由器本地ip – Aidin
对不起,我犯了一个错误私人IP实际上是192.168.0.2。如何在节点js中使用我的公共ip? – Bob
看到我发布的链接。另外,请在这里插入你的nodejs代码。 – Aidin