Set up node so it is externally visible?

后端 未结 2 372
失恋的感觉
失恋的感觉 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:28

    There is no configuration needed to make your external IP address work with node.js, unless and until you bind it otherwise.

    Instead of .listen(PORT, IP_ADDRESS_OR_HOST ); use .listen(PORT);

    Then, just use IP_ADDRESS_OR_HOST:PORT to access it.

    0 讨论(0)
  • 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/');
    
    0 讨论(0)
提交回复
热议问题