繁体   English   中英

配置node.js windows 2008服务器

[英]configuration node.js windows 2008 server

我确实将所有需要的软件包和node.js安装到专用机器Windows 2008 Server。

 var http = require('http');
 var port = 1337;
 http.createServer(function (req, res) {
      res.writeHead(200, {'Content-Type': 'text/plain'});
      res.end('Hello World\n');
 }).listen(port, '127.0.0.1');
console.log('Server running at http://127.0.0.1:' + port );

所以当我打电话给http://local.host:1337/时 ,我会得到'Hello World'但是如果尝试从另一台机器调用这个服务: http://my.domain.ip.address:1337 / Ooops ,我可以什么也看不见。 我已经完全关掉了防火墙

谢谢,所有的建议

侦听localhost127.0.0.1仅允许响应从同一台计算机发出的请求到该特定IP或主机名。

要让您的应用程序响应多个IP地址的请求,您需要收听它们中的每一个。 您可以单独执行此操作。

function server(req, res) {
    // ...
}

http.createServer(server).listen(port, '127.0.0.1');
http.createServer(server).listen(port, 'my.domain.ip.address');
http.createServer(server).listen(port, '<any other public facing IP address>');

或者,您可以在非特定的元地址中侦听IPADDR_ANY0.0.0.0 )。 并且,这是hostname参数的默认值,因此您只需指定port

http.createServer(function (req, res) {
    // ...
}).listen(port);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM