Skip to content

Instantly share code, notes, and snippets.

@njvack
Created February 3, 2012 19:38
Show Gist options
  • Save njvack/1731959 to your computer and use it in GitHub Desktop.
Save njvack/1731959 to your computer and use it in GitHub Desktop.
Trivial fix for HTTP_HOST problems with reverse-proxied Django
"""
Simply copies the X_FORWARDED crap into HTTP_HOST and SERVER_NAME.
"""
class SetHostname(object):
def process_request(self, request):
request.META['HTTP_HOST'] = request.META['HTTP_X_FORWARDED_HOST']
request.META['SERVER_NAME'] = request.META['HTTP_X_FORWARDED_SERVER']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment