NodeJs(Express)不会在ubuntu中监听IP和主机

时间:2016-02-08 07:44:27

标签: node.js express

我已将我的应用部署到ununtu。

这是bin / www:

app.set('port', 3000);
app.set('host','app.site.com');
var server = http.createServer(app);
server.listen(port,'64.143.255.122');//I put here a fake IP (deployed with the real one)
server.on('error', onError);
server.on('listening', onListening);

我在自己的电脑上创建了一个主机:64.143.255.122 app.site.com我打开浏览器:http://app.site.com:3000但它不起作用。

但是,如果我通过lynx,在服务器内部,并写lynx http://localhost:3000它将起作用,我会得到正确的页面。

可能是什么问题?

由于

1 个答案:

答案 0 :(得分:1)

你是否让iptables允许它?

试试这个:

iptables -A INPUT -p tcp --dport 3000 -j ACCEPT