Skip to content

Instantly share code, notes, and snippets.

@lakenen
Last active August 29, 2015 14:06
Show Gist options
  • Save lakenen/c80c1f47edf88ad8ded9 to your computer and use it in GitHub Desktop.
Save lakenen/c80c1f47edf88ad8ded9 to your computer and use it in GitHub Desktop.
Django middleware to capture X-Forwarded-Host and X-Forwarded-Port headers
class XForwarded(object):
def process_request(self, request):
try:
request.META['HTTP_HOST'] = request.META['HTTP_X_FORWARDED_HOST']) + ":" + str(request.META['HTTP_X_FORWARDED_PORT'])
except KeyError:
pass
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment