It should be easy to set up a forward proxy #301

ddopson opened this Issue Aug 24, 2012 · 2 comments


None yet
3 participants

ddopson commented Aug 24, 2012

node-http-proxy is great for reverse proxies. It's also wildly intimidating at first glance.

Sometimes you just want a simple vanilla forward-proxy. Also, forward proxying is conceptually simpler to explain. Thus here's two suggestions:

  1. Start the documentation with a forward proxy example ... it's a clean way of explaining the core proxy loop.


var server = HttpProxy.createServer(function (req, res, proxy) {
  url = Url.parse(req.url);
  host =;
  port = url.port || 80;
  console.log("Proxying #{host}:#{port}");
  proxy.proxyRequest(req, res, {
    port: port,
    host: host,
    https: true

And perhaps a quick "terms definition" would be helpful. forward_proxy=xxx, reverse_proxy=yyyy

  1. How on earth do you proxy an HTTPS request?????

I got as far as this:

module.exports = HttpProxy.createServer {
  https: {
    key: fs.readFileSync('server.key'),
    cert: fs.readFileSync('server.crt')
}, (req, res, proxy) ->
  url = Url.parse(req.url)
  port = url.port || 443 
  console.log "Proxying #{}:#{port}"
  proxy.proxyRequest(req, res, {
    port: port
    https: true

But it didn't work. I get "Proxy CONNECT aborted" when I do "curl" --proxy1.0 localhost:7878

This is EXACTLY what I want to do! I want to write my own "Forward Proxy" according to the definition

This is the type of proxy you can configure a system to use

The documentation only addresses the "user story":
When a browser make a request on the port that this proxy is listening to, forward it to a specific port on a specific host.

That is technically creating a "Reverse Proxy" To people who understand the networking technology and jargon, it is very confusing that the "forward" option to httpProxy.createServer creates a Reverse Proxy.

The "user story" that we are interested in is:
When this proxy is specified as a app specific or system wide HTTP/web proxy, forward the request to the requested URL and apply the specifies callback.

I cannot find ANY documentation on how to do this because of the misuse of the term "forward" in node-http-proxy's API. Sigh.

indexzero closed this Feb 12, 2013

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