1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-21 07:29:37 +01:00

up-storage: don't send X-Forwarded-For for proxies

It's not that important a feature to have, and it could break
some proxies.

ref https://github.com/rlidwka/sinopia/issues/254
This commit is contained in:
Alex Kocharin 2015-05-30 18:39:47 +03:00
parent 7c822d06f6
commit 0d266be965

@ -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