Skip to content

Instantly share code, notes, and snippets.

@nnnnathann
Last active August 29, 2015 13:59
Show Gist options
  • Save nnnnathann/10480208 to your computer and use it in GitHub Desktop.
Save nnnnathann/10480208 to your computer and use it in GitHub Desktop.
var util = require('util'),
colors = require('colors'),
http = require('http'),
httpProxy = require('http-proxy');
var localServerIp = '192.168.1.12';
//
// Http Proxy Server with Proxy Table
//
httpProxy.createServer({
router: {
'login.oberd.dev': localServerIp,
'form.oberd.dev': localServerIp,
'media.oberd.dev': localServerIp,
'cpanel.oberd.dev': localServerIp,
'portal.oberd.dev': localServerIp
}
}).listen(8001);
//
// Target Http Server
//
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
res.end();
}).listen(9000);
util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8001 '.yellow + 'with proxy table'.magenta.underline);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment