title: Running Node server takes over entire server and makes other project directory inaccessible, even with node-http-proxy
body: <p>I am transitioning a traditional LAMP-stack app to a NodeJS equivalent. However, there are multiple projects on the dev server, all shared between different teams. My app files exist in <code>/projects/1/</code> directory, but as soon as I browse <code>cd</code> into the directory and hit <code>npm start</code>, the app runs on <code>http://dev.test.com:3000</code>. In some cases (randomly), going to <code>http://dev.test.com</code> automatically begins to redirect to the node app on port 3000, making it impossible for any team member to access their project. What I would like is that when I start the server, it runs just inside the <code>/projects/1/</code> directory. It doesn't matter whether it runs in <code>http://test.dev.com:3000/projects/1/</code> or <code>http://test.dev.com/projects/1/</code>, but I need it to run inside that directory, not take over the entire server.</p>
  
  <p>I discussed this in the JavaScript room and was recommended to look into reverse proxies. Upon researching, I discovered <a href="https://github.com/nodejitsu/node-http-proxy" rel="nofollow">node-http-proxy</a> and installed it. But now, <code>http://dev.test.com:3000</code>, refuses to load altogether, meaning I went one step back instead of forward.</p>
  
  <p>Here is <code>routes/index.js</code>:</p>
  
  <pre><code>var express = require("express");
  var router = express.Router();
  var httpProxy = require("http-proxy");
  var apiProxy = httpProxy.createProxyServer();
  
  router.get("/projects/1/*", function(req, res) {
    apiProxy.web(req, res, { target: 'http://dev.test.com:3000' });
  });
  
  router.get("/", function(req, res, next) {
    console.log("hi");
  });
  
  module.exports = router;
  </code></pre>
  
  <p>I can see "hi" in the console, but the page is forever loading. I'd be happy to provide more code/info if need be.</p>