summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSantiago Gala <sgala@apache.org>2010-03-13 14:58:24 +0100
committerMarcel Hellkamp <marc@gsites.de>2010-03-13 20:40:48 +0100
commit482b9292ad2b319911863fea45f26fdab9d37e08 (patch)
tree033f9a3fc28c814a9737486f97f336825e8ecd59
parenta99242eb0c5ace037376a15b86a2df37f2092666 (diff)
downloadbottle-482b9292ad2b319911863fea45f26fdab9d37e08.tar.gz
Use the X-Forwarded-Host header, if present, for the URL
When reverse proxied, the HTTP_HOST header reflects the wrong request and will break redirect() and other operations. So, when the X-Forwarded-Host header is present, use it to compute the request.url property.
-rwxr-xr-xbottle.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/bottle.py b/bottle.py
index 326c7df..6d87cee 100755
--- a/bottle.py
+++ b/bottle.py
@@ -623,7 +623,7 @@ class Request(threading.local, DictMixin):
and includes scheme, host, port, scriptname, path and query string.
"""
scheme = self.environ.get('wsgi.url_scheme', 'http')
- host = self.environ.get('HTTP_HOST', None)
+ host = self.environ.get('HTTP_X_FORWARDED_HOST', self.environ.get('HTTP_HOST', None))
if not host:
host = self.environ.get('SERVER_NAME')
port = self.environ.get('SERVER_PORT', '80')