我正在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...");
从Windows计算机连接到Linux计算机上的node.js http服务器
和别的。
如果您的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] 删除。
我来说两句