Set up node so it is externally visible?

后端 未结 2 436
失恋的感觉
失恋的感觉 2020-12-16 13:08

Newbie question - might be more appropriate for ServerFault, apologies if so.

I\'m setting up node on Ubuntu 11.10, following the excellent howtonode instructions o

2条回答
  •  情歌与酒
    2020-12-16 13:45

    You can set up Node to listen on any IP/port, check out http://nodejs.org/docs/v0.6.3/api/http.html#server.listen

    Or a quick modified example from the link you supplied:

    var http = require('http');
    
    http.createServer(function (req, res) {
      res.writeHead(200, {'Content-Type': 'text/plain'});
      res.end('Hello Node.js\n');
    }).listen(80, "192.168.1.1");
    
    console.log('Server running at http://192.168.1.1:80/');
    

提交回复
热议问题