Skip to content

Instantly share code, notes, and snippets.

Created February 19, 2014 06:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
URL to host rewrite proxying with node-http-proxy
var httpProxy = require('http-proxy')
var proxy = httpProxy.createProxy();
var fulltld = '';
var options = {
'/first-target': 'first-target',
'/second-target': 'second-target'
require('http').createServer(function(req, res) {
if (!options[req.url]) {
return res.end(400);
// Need to change the URL here.
var dest = req.url;
req.url = '/';
proxy.web(req, res, {
target: options[req.url] + '.' + fulltld;
Copy link

And how can I rewrite the host but PREVIOUSLY get the data from the req.on('data') event?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment