title: Host multiple websites using Node.js Express
body: <p>I am having problems configuring two different Node.js applications with different domains. Have two directories </p>
  
  <pre><code>"/abc/" -&gt; express-admin setup (backend) -&gt; admin.abc.com
  </code></pre>
  
  <p>and </p>
  
  <pre><code>"/xyz/" -&gt; express setup (frontend) -&gt; abc.com
  </code></pre>
  
  <p>I need <strong><em>admin.abc.com</em></strong> to point to express-admin setup and <strong><em>abc.com</em></strong> to express setup. I have <strong>vhost</strong> installed and both the site listens to port 80. </p>
  
  <p>Have added</p>
  
  <pre><code>app.use(vhost('abc.com', app)); // xyz/app.js file
  app.use(vhost('admin.abc.com', app)); // abc/app.js file
  </code></pre>
  
  <p>My problems:</p>
  
  <ul>
  <li><p><strong><em>forever</em></strong> is installed, whenever i start both the apps, the second one is always stopped. I tried using different port for both apps but still having the same error. Individually they run without problems.</p></li>
  <li><p>I think my setup is too complicated for domain forwarding. Any better suggestions? May be I have a master app.js file which I can use to route the domains to their respective apps without using the app.js of each applications. </p></li>
  </ul>