1 var util = require('util'),
2 colors = require('colors'),
3 http = require('http'),
4 httpProxy = require('../../lib/node-http-proxy'),
5 Store = require('../helpers/store')
7 http.createServer(new Store().handler()).listen(7531)
9 // Now we set up our proxy.
10 httpProxy.createServer(
11 // This is where our middlewares go, with any options desired - in this case,
12 // the list of routes/URLs and their destinations.
13 require('proxy-by-url')({
14 '/store': { port: 7531, host: 'localhost' },
15 '/': { port: 9000, host: 'localhost' }
20 // Target Http Server (to listen for requests on 'localhost')
22 http.createServer(function (req, res) {
23 res.writeHead(200, { 'Content-Type': 'text/plain' });
24 res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
28 // And finally, some colored startup output.
29 util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
30 util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);