From e9b3ec9b1d0ebf427e138176b28af44f0f973670 Mon Sep 17 00:00:00 2001 From: indexzero Date: Thu, 19 May 2011 02:27:38 -0400 Subject: [PATCH] [fix] Set `x-forwarded-for` from req.connection.socket.remoteAddress if req.connection.remoteAddress is not defined --- 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 df3d6dc..43fa054 100644 --- a/lib/node-http-proxy.js +++ b/lib/node-http-proxy.js @@ -346,7 +346,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) { // // Add `x-forwarded-for` header to availible client IP to apps behind proxy // - req.headers['x-forwarded-for'] = req.connection.remoteAddress; + req.headers['x-forwarded-for'] = req.connection.remoteAddress || req.connection.socket.remoteAddress; // // Emit the `start` event indicating that we have begun the proxy operation.