Commit de4a6fe8 authored by indexzero's avatar indexzero

[fix] Only set `x-forward-*` headers if req.connection and req.connection.socket

parent 340be427
...@@ -126,10 +126,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { ...@@ -126,10 +126,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
// * `x-forwarded-proto`: Protocol of the original request // * `x-forwarded-proto`: Protocol of the original request
// * `x-forwarded-port`: Port of the original request. // * `x-forwarded-port`: Port of the original request.
// //
if (this.enable.xforward) { if (this.enable.xforward && req.connection && req.connection.socket) {
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-port'] = req.connection.remotePort || req.connection.socket.remotePort;
req.headers['x-forwarded-proto'] = res.connection.pair ? 'https' : 'http'; req.headers['x-forwarded-proto'] = req.connection.pair ? 'https' : 'http';
} }
// //
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment