Question regarding changing url with proxyRequest #435

fostahgix opened this Issue Jun 21, 2013 · 2 comments


None yet

2 participants


More of a question than an issue..

The Issue: When manually changing the to a remote host (''(and some other custom logic)), the url in the the browser is not changing.

Note: I thought this was working, however when using as my example, it turned out google was detecting the proxy and changing the host.

Question: Is there a way to change the url in the browser to a remote host (ie., everytime? Thanks!

Example: -> would change url in the browser to

The code I am using to do this currently:
var util = require('util'),
colors = require('colors'),
http = require('http'),
httpProxy = require('../../lib/node-http-proxy');

// Http Server with proxyRequest Handler and Latency
var proxy = new httpProxy.RoutingProxy();
http.createServer(function (req, res) { = ''; // manually setting
// and some other custom logic before proxying...
var buffer = httpProxy.buffer(req);
setTimeout(function () {
proxy.proxyRequest(req, res, {
port: 80,
host: '',
buffer: buffer
}, 200);

Any help is greatly appreciated!


You're not looking for a proxy at all. You're looking for a way to redirect requests.

var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(301, { 'location': '' });
@mmalecki mmalecki closed this Jun 23, 2013

Thanks for the followup. The requirement was to evaluate the clients IP and user-agent evaluate` on some logic, either pass the request through to its original endpoint, or change the endpoint to a splash page.

So the flow on our system would be.
-User connects to our system.
-User navigates to
-That request(and all port 80 requests) is redirected to our proxy via iptables (ie. proxyserver:8004/?url=
-The proxy determines if the request should continue to or be redirected to

So if we just do a 301, I think we will get into an endless loop of redirects. Is there anyway to just change the endpoint of the request while changing url in the browser so it is transparent to the user that their request being evaluated before being passed through? Thanks for any advice on this!

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