Skip to content

Commit

Permalink
[fix] x-forwarded http headers should set properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfhbrook committed Sep 20, 2011
1 parent 787370e commit 2677bb6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/node-http-proxy/http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
// * `x-forwarded-proto`: Protocol of the original request
// * `x-forwarded-port`: Port of the original request.
//
if (this.enable.xforward && req.connection && req.connection.socket) {

if (this.enable.xforward && req.connection && req.socket) {
req.headers['x-forwarded-for'] = req.connection.remoteAddress || req.connection.socket.remoteAddress;
req.headers['x-forwarded-port'] = req.connection.remotePort || req.connection.socket.remotePort;
req.headers['x-forwarded-port'] = req.connection.remotePort || req.socket.remotePort;
req.headers['x-forwarded-proto'] = req.connection.pair ? 'https' : 'http';
}

Expand Down Expand Up @@ -763,4 +764,4 @@ HttpProxy.prototype._forwardRequest = function (req) {
req.on('end', function () {
forwardProxy.end();
});
};
};

0 comments on commit 2677bb6

Please sign in to comment.