Skip to content

Commit 2677bb6

Browse files
committed
[fix] x-forwarded http headers should set properly.
1 parent 787370e commit 2677bb6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/node-http-proxy/http-proxy.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
128128
// * `x-forwarded-proto`: Protocol of the original request
129129
// * `x-forwarded-port`: Port of the original request.
130130
//
131-
if (this.enable.xforward && req.connection && req.connection.socket) {
131+
132+
if (this.enable.xforward && req.connection && req.socket) {
132133
req.headers['x-forwarded-for'] = req.connection.remoteAddress || req.connection.socket.remoteAddress;
133-
req.headers['x-forwarded-port'] = req.connection.remotePort || req.connection.socket.remotePort;
134+
req.headers['x-forwarded-port'] = req.connection.remotePort || req.socket.remotePort;
134135
req.headers['x-forwarded-proto'] = req.connection.pair ? 'https' : 'http';
135136
}
136137

@@ -763,4 +764,4 @@ HttpProxy.prototype._forwardRequest = function (req) {
763764
req.on('end', function () {
764765
forwardProxy.end();
765766
});
766-
};
767+
};

0 commit comments

Comments
 (0)