#9064: Redirect is broken when HTTP_X_FORWARDED_HOST contains multiple hosts
------------------------------------+---------------------------------------
Reporter: Artur | Owner: nobody
Status: new | Milestone:
Component: HTTP handling | Version: 1.0
Resolution: | Keywords:
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
------------------------------------+---------------------------------------
Comment (by louis):
Ran into problem myself. Using django (1.1.1 final), mod_python, apache2
and nginx (as proxy).
The previous patch didn't work in my case but below did:
{{{
LINE 45:
def get_host(self):
"""Returns the HTTP host using the environment or request
headers."""
# We try three options, in order of decreasing preference.
if 'HTTP_X_FORWARDED_HOST' in self.META:
host = self.META['HTTP_X_FORWARDED_HOST']
host = host.split(',')[-1].strip()
elif 'HTTP_HOST' in self.META:
host = self.META['HTTP_HOST']
host = host.split(',')[-1].strip()
else:
# Reconstruct the host using the algorithm from PEP 333.
host = self.META['SERVER_NAME']
host = host.split(',')[-1].strip()
server_port = str(self.META['SERVER_PORT'])
if server_port != (self.is_secure() and '443' or '80'):
host = '%s:%s' % (host, server_port)
return host
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/9064#comment:6>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.