mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[api] Add x-forwarded-proto and x-forwarded-port to proxied HTTP requests
This commit is contained in:
parent
e9b3ec9b1d
commit
421895fa30
@ -344,9 +344,16 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
|
||||
}
|
||||
|
||||
//
|
||||
// Add `x-forwarded-for` header to availible client IP to apps behind proxy
|
||||
// Add common proxy headers to the request so that they can
|
||||
// be availible to the proxy target server:
|
||||
//
|
||||
// * `x-forwarded-for`: IP Address of the original request
|
||||
// * `x-forwarded-proto`: Protocol of the original request
|
||||
// * `x-forwarded-port`: Port of the original request.
|
||||
//
|
||||
req.headers['x-forwarded-for'] = req.connection.remoteAddress || req.connection.socket.remoteAddress;
|
||||
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-proto'] = res.connection.pair ? 'https' : 'http';
|
||||
|
||||
//
|
||||
// Emit the `start` event indicating that we have begun the proxy operation.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user