Skip to content

Commit f6dc12a

Browse files
committed
[fix] Use req.connection for all x-forward-* headers
1 parent 216d46d commit f6dc12a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: lib/node-http-proxy.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
433433
// * `x-forwarded-proto`: Protocol of the original request
434434
// * `x-forwarded-port`: Port of the original request.
435435
//
436-
if (options.enableXForwarded === true && req.connection) {
436+
if (options.enableXForwarded === true && req.connection && req.connection.socket) {
437437
req.headers['x-forwarded-for'] = req.connection.remoteAddress || req.connection.socket.remoteAddress;
438438
req.headers['x-forwarded-port'] = req.connection.remotePort || req.connection.socket.remotePort;
439-
req.headers['x-forwarded-proto'] = res.connection.pair ? 'https' : 'http';
439+
req.headers['x-forwarded-proto'] = req.connection.pair ? 'https' : 'http';
440440
}
441441

442442
//

0 commit comments

Comments
 (0)