From de4a6fe8a5f78460b030e635e5f4a63312cd4a76 Mon Sep 17 00:00:00 2001 From: indexzero Date: Sun, 28 Aug 2011 21:21:35 -0400 Subject: [PATCH] [fix] Only set `x-forward-*` headers if req.connection and req.connection.socket --- lib/node-http-proxy/http-proxy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index 223452e..5e9116c 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -126,10 +126,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) { + if (this.enable.xforward && req.connection && req.connection.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-proto'] = res.connection.pair ? 'https' : 'http'; + req.headers['x-forwarded-proto'] = req.connection.pair ? 'https' : 'http'; } //