Skip to content

Commit 5251a23

Browse files
committed
Merge branch 'customizeOutgoingAddress' of github.com:sberan/node-http-proxy into sberan-customizeOutgoingAddress
Conflicts: lib/http-proxy.js lib/http-proxy/common.js
2 parents 89a22bc + e633b0f commit 5251a23

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

lib/http-proxy.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = httpProxy.Server;
1111
module.exports.createProxy = function(options) {
1212
return {
1313
web: httpProxy.createRightProxy('web')(options),
14-
ws: httpProxy.createRightProxy('ws')(options)
14+
ws: httpProxy.createRightProxy('ws')(options)
1515
};
1616
}
1717

@@ -43,6 +43,7 @@ module.exports.createProxyServer = module.exports.createServer = function create
4343
* xfwd : <true/false, adds x-forward headers>
4444
* secure : <true/false, verify SSL certificate>
4545
* toProxy: <true/false, explicitly specify if we are proxying to another proxy
46+
* localAddress : <Local interface string to bind for outgoing connections>
4647
* }
4748
*
4849
* NOTE: `options.ws` and `options.ssl` are optional.

lib/http-proxy/common.js

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
4444

4545

4646
outgoing.agent = options.agent || false;
47+
outgoing.localAddress = options.localAddress;
4748

4849
//
4950
// Remark: If we are false set the connection: close. This is the right thing to do

test/lib-http-proxy-common-test.js

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe('lib/http-proxy/common.js', function () {
1515
port : 'you',
1616
},
1717
headers: {'fizz': 'bang', 'overwritten':true},
18+
localAddress: 'local.address',
1819
},
1920
{
2021
method : 'i',
@@ -34,6 +35,7 @@ describe('lib/http-proxy/common.js', function () {
3435
expect(outgoing.headers.pro).to.eql('xy');
3536
expect(outgoing.headers.fizz).to.eql('bang');
3637
expect(outgoing.headers.overwritten).to.eql(true);
38+
expect(outgoing.localAddress).to.eql('local.address');
3739
});
3840

3941
it('should set the agent to false if none is given', function () {

0 commit comments

Comments
 (0)