[fix] x-forwarded http headers should set properly.

This commit is contained in:
Joshua Holbrook 2011-09-20 13:00:59 -07:00
parent 787370ee87
commit 2677bb6c44

View File

@ -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();
});
};
};