summaryrefslogtreecommitdiff
path: root/routes/__init__.py
diff options
context:
space:
mode:
authorBen Bangert <ben@groovie.org>2015-01-17 10:38:37 -0800
committerBen Bangert <ben@groovie.org>2015-01-17 10:38:37 -0800
commit9fe1e17a0b4a53b915c56ef440ed4f2f47400c88 (patch)
tree6a8422f555dcaee6b5a2e5bd43a070cd89a74349 /routes/__init__.py
parent93470a86317342d2298ad393c5993b2ec07348ad (diff)
downloadroutes-9fe1e17a0b4a53b915c56ef440ed4f2f47400c88.tar.gz
* Use the first X_FORWARDED_FOR value if there are multiple proxies in the
path. Fixes #5.
Diffstat (limited to 'routes/__init__.py')
-rw-r--r--routes/__init__.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/routes/__init__.py b/routes/__init__.py
index ae9a21b..76c19fa 100644
--- a/routes/__init__.py
+++ b/routes/__init__.py
@@ -60,7 +60,10 @@ class _RequestConfig(object):
pass
if 'HTTP_X_FORWARDED_HOST' in environ:
- self.__shared_state.host = environ['HTTP_X_FORWARDED_HOST']
+ # Apache will add multiple comma separated values to
+ # X-Forwarded-Host if there are multiple reverse proxies
+ self.__shared_state.host = \
+ environ['HTTP_X_FORWARDED_HOST'].split(', ', 1)[0]
elif 'HTTP_HOST' in environ:
self.__shared_state.host = environ['HTTP_HOST']
else: