From f31b61ea5b3cdecce24aa4dbda4e6b7370bfdae9 Mon Sep 17 00:00:00 2001 From: Jason Michalski Date: Wed, 12 Feb 2014 11:36:21 -0500 Subject: [PATCH] Pass the client's Host header to django as X-Forwarded-Host This allows Django to build correct redirects to hostnames other than localhost. (imported from commit 886b345f29fc03518cedd93ecbcea0be251f3230) --- tools/run-dev.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/run-dev.py b/tools/run-dev.py index 06c607f762..e15e6285ab 100755 --- a/tools/run-dev.py +++ b/tools/run-dev.py @@ -55,7 +55,6 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) proxy_port = base_port django_port = base_port+1 tornado_port = base_port+2 -proxy_host = 'localhost:%d' % (proxy_port,) os.chdir(os.path.join(os.path.dirname(__file__), '..')) @@ -83,7 +82,9 @@ for cmd in cmds: class Resource(resource.Resource): def getChild(self, name, request): - request.requestHeaders.setRawHeaders('X-Forwarded-Host', [proxy_host]) + # Assume an HTTP 1.1 request + proxy_host = request.requestHeaders.getRawHeaders('Host') + request.requestHeaders.setRawHeaders('X-Forwarded-Host', proxy_host) if (request.uri in ['/json/get_events'] or request.uri.startswith('/json/events') or