Last active
August 29, 2015 13:59
-
-
Save nnnnathann/10480208 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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