Skip to content

Commit

Permalink
[fix] Only set x-forward-* headers if req.connection and req.connec…
Browse files Browse the repository at this point in the history
…tion.socket
  • Loading branch information
indexzero committed Aug 29, 2011
1 parent 340be42 commit de4a6fe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/node-http-proxy/http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,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) {
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-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';
}

//
Expand Down

0 comments on commit de4a6fe

Please sign in to comment.