我正在 Node.js 主页上尝试这个简单的演示:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
我已经在其安全组中打开了亚马逊 EC2 (1337) 上的端口。
[root@domU-12-31-38-01-8A-8D servers]# /usr/local/bin/node nodeexample.js
Server running at http://127.0.0.1:1337/
我什么也没得到,但典型的服务器没有响应。请帮助这个菜鸟
蛋壳
你正在听127.0.0.1
这使得节点只监听环回接口并且只允许它到达来自本地主机本身.
如果你听0.0.0.0
相反,你会听到all机器的网络接口,让您可以通过机器正在使用的任何公共 IP 通过 Internet 进行访问。这可能就是您想要的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)