From 2677bb6c44244ea0b584db744955bedf7aee2c62 Mon Sep 17 00:00:00 2001 From: Joshua Holbrook Date: Tue, 20 Sep 2011 13:00:59 -0700 Subject: [PATCH] [fix] x-forwarded http headers should set properly. --- lib/node-http-proxy/http-proxy.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index 9b4ef59..84ba1ac 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -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'; } @@ -763,4 +764,4 @@ HttpProxy.prototype._forwardRequest = function (req) { req.on('end', function () { forwardProxy.end(); }); -}; \ No newline at end of file +};