From 62201a0917271db4ed0a08fc6f39e3fc76e8c178 Mon Sep 17 00:00:00 2001 From: isaacs Date: Sun, 28 Aug 2011 13:41:05 -0700 Subject: [PATCH] Fix #95 Don't look on req.connection if it's not set. --- lib/node-http-proxy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node-http-proxy.js b/lib/node-http-proxy.js index e0a27e0..cef3934 100644 --- a/lib/node-http-proxy.js +++ b/lib/node-http-proxy.js @@ -428,7 +428,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) { // * `x-forwarded-proto`: Protocol of the original request // * `x-forwarded-port`: Port of the original request. // - if (options.enableXForwarded === true) { + if (options.enableXForwarded === true && req.connection) { 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';