我在Rackspace中部署了一个nodejs服务器,可以在内部访问,例如使用:
curl http://127.0.0.1:8080
但是,即使我这样做,也无法从外部(互联网)访问它:
iptables -A OUTPUT -p tcp --dport 8080 -j ACCEPT
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
我的代码如下所示:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Simple server\n');
}).listen(8080, "0.0.0.0");
console.log('Server running at http://0.0.0.0:8080/');
有任何想法吗?
我认为你应该尝试不指定IP。
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Simple server\n');
}).listen(8080);
console.log('Server running at http://0.0.0.0:8080/');
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)