Skip to content

Commit e9b3ec9

Browse files
committed
[fix] Set x-forwarded-for from req.connection.socket.remoteAddress if req.connection.remoteAddress is not defined
1 parent f1c0f64 commit e9b3ec9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/node-http-proxy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
346346
//
347347
// Add `x-forwarded-for` header to availible client IP to apps behind proxy
348348
//
349-
req.headers['x-forwarded-for'] = req.connection.remoteAddress;
349+
req.headers['x-forwarded-for'] = req.connection.remoteAddress || req.connection.socket.remoteAddress;
350350

351351
//
352352
// Emit the `start` event indicating that we have begun the proxy operation.

0 commit comments

Comments
 (0)