Skip to content

Commit

Permalink
Fix bug: x-forwarded-proto set incorrectly
Browse files Browse the repository at this point in the history
When routed via multiple proxies, x_forwarded_proto set as httphttps or
wswss instead of http,https or ws,wss, since + operator seems to have a
higher precedence than the terniary operator and the expression was
getting evaluated to true always
  • Loading branch information
rampr committed Jun 19, 2012
1 parent 81f6095 commit 0933f1c
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 @@ -148,7 +148,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
}

if (req.headers['x-forwarded-proto']){
var protoToAppend = "," + (req.connection.pair) ? 'https' : 'http';
var protoToAppend = "," + (req.connection.pair ? 'https' : 'http');
req.headers['x-forwarded-proto'] += protoToAppend;
}
else {
Expand Down Expand Up @@ -415,7 +415,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
}

if (req.headers['x-forwarded-proto']){
var protoToAppend = "," + (req.connection.pair) ? 'wss' : 'ws';
var protoToAppend = "," + (req.connection.pair ? 'wss' : 'ws');
req.headers['x-forwarded-proto'] += protoToAppend;
}
else {
Expand Down

0 comments on commit 0933f1c

Please sign in to comment.