Created
September 21, 2011 12:53
-
-
Save dolugen/1231953 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from http://docs.webfaction.com/software/django/troubleshooting.htmlhighlight=django%20remote%20addres#accessing-remote-addr | |
class WebFactionFixes(object): | |
"""Sets 'REMOTE_ADDR' based on 'HTTP_X_FORWARDED_FOR', if the latter is | |
set. | |
Based on http://djangosnippets.org/snippets/1706/ | |
""" | |
def process_request(self, request): | |
if 'HTTP_X_FORWARDED_FOR' in request.META: | |
ip = request.META['HTTP_X_FORWARDED_FOR'].split(",")[0].strip() | |
request.META['REMOTE_ADDR'] = ip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment