#2552: [contrib] get IP from X-Forwarded-For
-----------------------------+----------------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: adrian
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: Metasystem | Version:
Severity: normal | Keywords:
-----------------------------+----------------------------------------------
SmileyChris suggest this would be contrib worthy.
from [http://feh.holsman.net/articles/2006/08/16/handy-django-middleware-
for-shared-hosting myblog]
on some shared hosting environments like webfaction they install a reverse
proxy solution where you run a apache2 webserver on a custom port, and the
main webserver forwards the request through to you.
This works great, and I’ve been using things like this for years, but the
problem you get is that all the requests appear to be from 127.0.0.1 (or
the machine which is doing the proxying for you) which isn’t the best if
you want to record that stuff.
webfaction fixes this in the log files for you automatically, but that
doesn’t help you if you want to do something with the IP# in django.
enter FixIP it takes the X-Forwarded-For header sent by compliant servers
which holds the real IP and makes django work properly.
installation is easy.. just add the routine to your middleware settings
ala
{{{
MIDDLEWARE_CLASSES = (
"django.middleware.common.CommonMiddleware",
"zilbo.common.utils.middleware.fixip.FixIP",
...
}}}
code is available [http://svn.zyons.python-
hosting.com/trunk/zilbo/common/utils/middleware/fixip.py here]
--
Ticket URL: <http://code.djangoproject.com/ticket/2552>
Django <http://code.djangoproject.org/>
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
-~----------~----~----~----~------~----~------~--~---