外网不能访问部署在虚机的NodeJs网站(80端口)

    外网能访问部署在虚机的NodeJs网站需注意如下:

    1. 在管理门户上配置端点(Http 80->80)

    clip_image001

    1. 在虚机中的防火墙入站规则中增加应用程序Node.exe的允许规则

    clip_image002

    1. 启动NodeJs的侦听进程时,需要侦听所有IP(0.0.0.0)

    示例代码如下:

    var http = require('http');

    http.createServer(function (req, res) {

      res.writeHead(200, {'Content-Type': 'text/plain'});

      res.end('Hello World\n');

    }).listen(80,"0.0.0.0");

    console.log('Server running.');

posted @ 2014-05-07 22:28  EricWen  阅读(4479)  评论(0编辑  收藏  举报