var httpProxy = require('http-proxy');
var proxy = httpProxy.createProxy();

var options = {
  '127.0.0.1:8080': 'http://localhost:10000',
  'localhost:8080': 'http://localhost:10002'
}

require('http').createServer(function(req, res) {
  console.log(req.headers.host);
  console.log(options[req.headers.host]);

  proxy.web(req, res, {
    target: options[req.headers.host]
  }, function(e) {
    console.log(e);
  });
}).listen(8080);
@@ -73,311 +73,1137 @@
 ();%0A
-%0A
 var 
-options = %7B%0A  '127.0.0.1:8080': 'http://localhost:10000',%0A  'localhost:8080': 'http://localhost:10002'%0A%7D%0A%0Arequire('http').createServer(function(req, res) %7B%0A  console.log(req.headers.host);%0A  console.log(options%5Breq.headers.host%5D);%0A%0A  proxy.web(req, res, %7B%0A    target: options%5Breq.headers.host%5D%0A  %7D,
+urlparser = require('url');%0A%0Amodule.exports = exports = new function() %7B%0A%09var self = this;%0A%09this.websites = %5B%5D;%0A%09this.ports = %5B%5D;%0A%0A%0A%09this.serverWorker = function(req, res) %7B%0A%09%09var host = req.headers.host;%0A%09%09var website = self.getWebsiteFromUrl(host);%0A%0A%09%09if(website == null) %7B%0A%09%09%09res.end();%0A%09%09%09return;%0A%09%09%7D%0A%0A%09%09proxy.web(req, res, %7B%0A%09%09%09target: website.target%0A%09%09%7D, function(e) %7B%0A%09%09%09console.log(e);%0A%09%09%7D);%0A%09%7D;%0A%0A%09this.server = require('http').createServer(this.serverWorker);%0A%09%0A%09this.getWebsiteFromUrl = function(url) %7B%0A%09%09var websitesCount = this.websites.length;%0A%0A%09%09for(var i = 0; i %3C websitesCount; i++) %7B%0A%09%09%09var website = this.websites%5Bi%5D;%0A%09%09%09var bindingsCount = website.bindings.length;%0A%0A%09%09%09for(var j = 0; j %3C bindingsCount; j++) %7B%0A%09%09%09%09var binding = website.bindings%5Bj%5D;%0A%0A%09%09%09%09if(binding == url) %7B%0A%09%09%09%09%09return website;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%0A%09this.addWebsite = function(website) %7B%0A%09%09/*var bindings = website.bindings;%0A%0A%09%09for(var i = 0; i %3C bindings.length; i++) %7B%0A%09%09%09bindings%5Bi%5D = urlparser.parse(bindings%5Bi%5D);%0A%09%09%7D*/%0A%0A%09%09this.websites.push(website);%0A%09%7D;%0A%0A%0A%09this.addPort = function(port) %7B%0A%09%09this.ports.push(port);%0A%09%7D;%0A%0A%0A%09this.start =
  fun
@@ -1212,51 +1212,277 @@
 ion(
-e
 ) %7B%0A
-    console.log(e);%0A  %7D);%0A%7D).listen(8080)
+%09%09var ports = this.ports.length;%0A%0A%09%09for(var i = 0; i %3C ports; i++) %7B%0A%09%09%09console.log(this.ports%5Bi%5D);%0A%09%09%09this.server.listen(this.ports%5Bi%5D);%0A%09%09%7D%0A%09%7D;%0A%0A%0A%09this.stop = function() %7B%0A%09%09this.server.close();%0A%09%7D;%0A%0A%0A%09this.restart = function() %7B%0A%09%09this.stop();%0A%09%09this.start();%0A%09%7D;%0A%7D
 ;

make a functionality server class