mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[fix] x-forwarded http headers should set properly.
This commit is contained in:
parent
787370ee87
commit
2677bb6c44
@ -128,9 +128,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
|
||||
// * `x-forwarded-proto`: Protocol of the original request
|
||||
// * `x-forwarded-port`: Port of the original request.
|
||||
//
|
||||
if (this.enable.xforward && req.connection && req.connection.socket) {
|
||||
|
||||
if (this.enable.xforward && req.connection && req.socket) {
|
||||
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-port'] = req.connection.remotePort || req.socket.remotePort;
|
||||
req.headers['x-forwarded-proto'] = req.connection.pair ? 'https' : 'http';
|
||||
}
|
||||
|
||||
@ -763,4 +764,4 @@ HttpProxy.prototype._forwardRequest = function (req) {
|
||||
req.on('end', function () {
|
||||
forwardProxy.end();
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user