title: How to not use localhost, but the IP of the server instead?
body: <p>I found this node application on <a href="http://tutorialzine.com/2014/03/nodejs-private-webchat/" rel="nofollow">this tutorial</a> and wanted to use it, but it's configured to run as localhost. Since the application is run on Amazon Linux EC2, there is no desktop (local) access to it (maybe there's software to install to enable desktop mode, but I haven't got that).</p>
  
  <p>I'd like to run the application on the server, not on localhost, but on the server's Elastic IP address which I'll be adding to a Hosted Zone of my domain chatxs.com.</p>
  
  <p>I'd like to make the app listen for any requests in this IP, which again, will be in the domain name's DNS.</p>
  
  <p>Here's the code the tutorial comes with, the only thing I've changed is the .html files in the views folder (styling, alignment and some text, no code changes of the app, just the html):</p>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>// This is the main file of our chat app. It initializes a new 
  // express.js instance, requires the config and routes files
  // and listens on a port. Start the application by running
  // 'node app.js' in your terminal
  
  var express = require('express'),
      app = express();
  
  // This is needed if the app is run on heroku:
  
  var port = process.env.PORT || 8080;
  
  // Initialize a new socket.io object. It is bound to 
  // the express app, which allows them to coexist.
  
  var io = require('socket.io').listen(app.listen(port));
  // Require the configuration and the routes files, and pass
  // the app and io as arguments to the returned functions.
  
  require('./config')(app, io);
  require('./routes')(app, io);
  
  console.log('Your application is running on http://localhost:' + port);
  </code></pre>
  
  <p><strong>config.js</strong></p>
  
  <pre><code>// This file handles the configuration of the app.
  // It is required by app.js
  
  var express = require('express');
  
  module.exports = function(app, io){
  
  // Set .html as the default template extension
  app.set('view engine', 'html');
  
  // Initialize the ejs template engine
  app.engine('html', require('ejs').renderFile);
  
  // Tell express where it can find the templates
  app.set('views', __dirname + '/views');
  
  // Make the files in the public folder available to the world
  app.use(express.static(__dirname + '/public'));
  
  };
  </code></pre>
  
  <p><a href="http://pastebin.com/r1jbk0M8" rel="nofollow">routes.js</a> it was too big to format it here.</p>
  
  <p>And finally</p>
  
  <p><strong>package.json</strong></p>
  
  <pre><code>{
  "name": "NodeChatSystem",
  "version": "0.0.1",
  "description": "Realtime chat system for Tutorialzine.com",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
  },
  "keywords": [
    "node",
    "chat",
    "system"
  ],
  "author": "Nikolay Anastasov",
  "license": "MIT",
  "dependencies": {
    "ejs": "^1.0.0",
    "express": "^4.8.2",
    "gravatar": "~1.0.6",
    "socket.io": "^1.0.6"
    }
  }
  </code></pre>
  
  <p>The above is basically what's included in the tutorial .zip file.</p>