Skip to content

Commit

Permalink
[fix] closes #547
Browse files Browse the repository at this point in the history
  • Loading branch information
yawnt committed Jan 16, 2014
1 parent 0ba4fa8 commit 4351ed1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/http-proxy.js
Expand Up @@ -8,6 +8,13 @@ var http = require('http'),
*/
module.exports = httpProxy.Server;

module.exports.createProxy = function(options) {
return {
web: httpProxy.createRightProxy('web')(options),
ws: httpProxy.createRightProxy('ws')(options)
};
}

/**
* Creates the proxy server.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/http-proxy/index.js
Expand Up @@ -80,7 +80,7 @@ function createRightProxy(type) {
};
};
}

httpProxy.createRightProxy = createRightProxy;

function ProxyServer(options) {
EE3.call(this);
Expand Down

1 comment on commit 4351ed1

@trusktr
Copy link

@trusktr trusktr commented on 4351ed1 Feb 8, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yawnt If you could add to the main documentation info regarding how to make "proxy tables" like in the example you've mentioned at https://blog.nodejitsu.com/node-http-proxy-1dot0/ that would be very helpful!

var httpProxy = require('http-proxy')

var proxy = httpProxy.createProxy();

var options = {
  'foo.com': 'website.com:8001',
  'bar.com': 'website2.com:8002'
}

require('http').createServer(function(req, res) {
  proxy.web(req, res, {
    target: options[req.headers.host]
  });
}).listen(8000);

^^^ If you could provide more examples of that type of usage, that would be extremely helpful. Thanks!

Please sign in to comment.