【发布时间】:2012-01-30 10:44:04
【问题描述】:
我到处寻找答案,但没有任何运气。
我已经在我的服务器上安装了 node.js。我创建了标准的“Hello World”示例,例如:
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8080, "0.0.0.0");
console.log('Server running at http://0.0.0.0:8080/');
在服务器上运行脚本后:
node app.js
我可以在内部连接到端口 808 并看到 Hello World 消息,但是当我尝试从外部连接到我的服务器的端口 8080 时,我收到“无法连接到服务器”错误。我也在我的监听函数中试过这个:
etc..
}).listen(8080, "204.xxx.xxx.xxx");
(使用我的真实外部 IP 地址)并且没有任何运气。
我已尝试通过将其添加到 iptables 来接受 8080 上的连接:
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
但还是碰壁了。当我运行 netstat 时,我得到:
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
我认为这告诉我端口 8080 正在侦听连接。
那么——我在这里做错了什么?
【问题讨论】:
-
操作系统防火墙软件怎么样?
标签: linux node.js external iptables