title: Router in Node http proxy
body: <p>Can anyone please explain what the router in options does in this code. I got this code from a blog. I am trying to implement node http-proxy.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>var http = require('http'),  
      httpProxy = require('http-proxy');
  
  //
  //Leave out the hostnameOnly field this time, or set it to false...
  //
  var options = {  
    router: {
      'domainone.com/appone': '127.0.0.1:9000',
      'domainone.com/apptwo': '127.0.0.1:9001',
      'domaintwo.net/differentapp': '127.0.0.1:9002'
    }
  }
  
  
  //
  //...and then pass in your options like last time.
  //
  var proxyServer = httpProxy.createServer(options).listen(80);
  
  //
  // ...and a simple http server to show us our request back.
  //
  http.createServer(function (req, res) {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
    res.end();
  }).listen(9000);</code></pre>
  </div>
  </div>
  </p>