- 在管理門戶上配置端點(Http 80->80)
- 在虛機中的防火牆入站規則中增加應用程序Node.exe的允許規則
- 啟動NodeJs的偵聽進程時,需要偵聽所有IP(0.0.0.0)
外網能訪問部署在虛機的NodeJs網站需注意如下:
示例代碼如下:
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.');