Skip to content

Commit

Permalink
up-storage: don't send X-Forwarded-For for proxies
Browse files Browse the repository at this point in the history
It's not that important a feature to have, and it could break
some proxies.

ref #254
  • Loading branch information
rlidwka committed May 30, 2015
1 parent 7c822d0 commit 0d266be
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/up-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,19 @@ Storage.prototype.search = function(startkey, options) {

Storage.prototype._add_proxy_headers = function(req, headers) {
if (req) {
headers['X-Forwarded-For'] = (
req && req.headers['x-forwarded-for']
? req.headers['x-forwarded-for'] + ', '
: ''
) + req.connection.remoteAddress
// Only submit X-Forwarded-For field if we don't have a proxy selected
// in the config file.
//
// Otherwise misconfigured proxy could return 407:
// https://github.com/rlidwka/sinopia/issues/254
//
if (!this.proxy) {
headers['X-Forwarded-For'] = (
req && req.headers['x-forwarded-for']
? req.headers['x-forwarded-for'] + ', '
: ''
) + req.connection.remoteAddress
}
}

// always attach Via header to avoid loops, even if we're not proxying
Expand Down

0 comments on commit 0d266be

Please sign in to comment.