无法通过内部/专用网络上的浏览器使用Node.js http服务器

马库斯

我正在Fedora 20上使用node.js运行“ hello world” http服务器。

通过在地址栏中键入以下任意内容,我可以使用Firefox查看“ hello world”:192.168.2.85,localhost,0.0.0.0、192.168.122.1

我想当妻子连接到同一个DCHP NAT路由器时,可以在她的计算机上打开浏览器,在地址栏中键入192.168.2.85,然后看到“ hello world”。

但是,她的Chrome33说“此网页不可用”或“糟糕!...无法连接到192.168.2.25”。她的IE9说:“ ...无法显示该网页。” 但是从她的命令提示符下,我可以ping 192.168.2.85。

在她的计算机上(Windows 7),我尝试关闭Windows防火墙并关闭防病毒功能。

在电脑上,我尝试

iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT

在我们的Microsoft路由器上,我尝试了永久端口转发(入站端口范围80-80,专用端口范围80-80,类型TCP,专用ip 192.168.2.85)和为192.168.2.85启用虚拟DMZ。(我希望我没有提供足够的信息来允许攻击?)我在路由器中没有看到对WDS的引用。

我该怎么做才能使我的node.js应用程序可用于我家中的其他计算机?我是这一切的新手。

这里有更多细节。

netstat -ntlp
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      4566/node   


cat test.js
var http = require("http");

var app = http.createServer(function(request, response) {
  response.writeHead(200, {
    "Content-Type": "text/plain"
  });
  response.end("hello world\n");
});

app.listen(80); //192.168.2.85  
console.log("Server running...");

我看过:无法通过移动设备浏览本地计算机上托管的网站

Node.js连接仅适用于本地主机

如何在端口80上运行Node.js?

从Windows计算机连接到Linux计算机上的node.js http服务器

Node.JS无法在Internet上运行

和别的。

土豆泥

如果您的Linux服务器没有GUI,则可以使用以下firewall-cmd命令手动设置防火墙...

# list current settings prior to changes; this is your baseline
firewall-cmd --zone=internal --list-all

# add the http services (https is optional based on your needs)
firewall-cmd --zone=internal --add-service=http
firewall-cmd --zone=internal --add-service=https

# I am using port 8080 with node.js just to differentiate it (optional)
firewall-cmd --zone=internal --add-port=8080/tcp

# the zone 'public' is the default zone on my machine but it is not
# associated with the eth0 network adapter.  however, the zone 'internal' is,
# therefore, make 'internal' the default zone
firewall-cmd --set-default-zone=internal

# make the changes permanent so that they are present between reboots
firewall-cmd --runtime-to-permanent

# reload all of the firewall rules for good measure
firewall-cmd --complete-reload

# list out the current settings after changes
firewall-cmd --zone=internal --list-all

而已。希望这对某人有帮助。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Node.js HTTP服务器

基于Node.js的服务器与类似Apache HTTP服务器的服务器

Ember通过外部HTTP服务器包含外部JS

Node.js HTTP服务器路由

Node JS作为HTTP服务器并托管angularJS SPA

node.js http服务器并发问题

在 express JS 服务器中使用 http-proxy

为什么Node.js简单的HTTP服务器应用程序无法在服务器上运行?

在Node.js上的相同地址上服务WebSocket和HTTP服务器

Azure 上的 Node Js RestFull API,返回 HTTP 错误 500.1001 - 内部服务器错误

具有http.createServer的服务器与在节点js中使用express的服务器之间的区别

在node.js上使用http服务器监听多个主机

如何在Node.js服务器上使用HTTP POST数据?

Node.js WebSocket服务器,HTTP触发器

如何使 node.js 服务器无法通过浏览器访问但仍可用于 nginx?

node.js服务器和带有express.js的HTTP / 2(2.0)

通过Node JS服务器中的http请求接收二进制数据

如何从浏览器上的网页更新 Node.js 服务器上的 JSON 数据?

Node.js快速文件服务器(HTTP上的静态文件)

套接字在http.request上挂接到Node.js MongoDb服务器

在Node.JS和Express中的HTTPS服务器上拦截HTTP响应

通过使用Angular JS的代理服务器的HTTP请求

使用node.js开发http服务器时的主要漏洞是什么

通过 ssh 在专用服务器上安装 node.js

无法使用浏览器使用http中的域名访问我的服务器

REACTJS xhr.js:177 POST http://localhost:3000/registerUser 500(内部服务器错误)

使用Node JS的肥皂服务器

如何从node.js Web服务器使用SOAP服务器

setInterval是否会阻止/干扰node.js / express HTTP服务器?