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)
This commit is contained in:
Jason Michalski 2014-02-12 11:36:21 -05:00
parent 502852541b
commit f31b61ea5b
1 changed files with 3 additions and 2 deletions

View File

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