aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2013-03-07 12:20:03 +0100
committerMarcin Kuzminski <marcin@python-works.com>2013-03-07 12:20:03 +0100
commitadb32b9f056afc9418f856956e2c50a3fd9c1168 (patch)
tree4533f1e4c47c8f462eb8e76c70d016101ea7fb9f
parent9088808144d9bdcae6fce6e1c27316d2f5249490 (diff)
handle all cases with proxy IP addresses, not only for X_FORWARDED_FOR
--HG-- extra : source : 64371c42e2f1ca9a6e7c01ad749657bd433567ba
-rw-r--r--rhodecode/lib/base.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py
index 873ece86..1144b8b9 100644
--- a/rhodecode/lib/base.py
+++ b/rhodecode/lib/base.py
@@ -43,15 +43,17 @@ def _get_ip_addr(environ):
ip = environ.get(proxy_key2)
if ip:
- # HTTP_X_FORWARDED_FOR can have mutliple ips inside
- # the left-most being the original client, and each successive proxy
- # that passed the request adding the IP address where it received the
- # request from.
- if ',' in ip:
- ip = ip.split(',')[0].strip()
return ip
ip = environ.get(def_key, '0.0.0.0')
+
+ # HEADERS can have mutliple ips inside
+ # the left-most being the original client, and each successive proxy
+ # that passed the request adding the IP address where it received the
+ # request from.
+ if ',' in ip:
+ ip = ip.split(',')[0].strip()
+
return ip