@@ -63,7 +63,7 @@ Adds a few conveniences for perfectionists:
6363 last component in the path contains a period. So ``foo.com/bar`` is
6464 redirected to ``foo.com/bar/``, but ``foo.com/bar/file.txt`` is passed
6565 through unchanged.
66-
66+
6767 If ``PREPEND_WWW`` is ``True``, URLs that lack a leading "www." will be
6868 redirected to the same URL with a leading "www."
6969
@@ -101,6 +101,22 @@ Handles conditional GET operations. If the response has a ``ETag`` or
101101Also removes the content from any response to a HEAD request and sets the
102102``Date`` and ``Content-Length`` response-headers.
103103
104+ django.middleware.http.SetRemoteAddrFromForwardedFor
105+ ----------------------------------------------------
106+
107+ **New in Django development version**
108+
109+ Sets ``request['REMOTE_ADDR']`` based on ``request.['HTTP_X_FORWARDED_FOR']``,
110+ if the latter is set. This is useful if you're sitting behind a reverse proxy
111+ that causes each request's ``REMOTE_ADDR`` to be set to ``127.0.0.1``.
112+
113+ **Important note:** This does NOT validate ``HTTP_X_FORWARDED_FOR``. If you're
114+ not behind a reverse proxy that sets ``HTTP_X_FORWARDED_FOR`` automatically, do
115+ not use this middleware. Anybody can spoof the value of
116+ ``HTTP_X_FORWARDED_FOR``, and because this sets ``REMOTE_ADDR`` based on
117+ ``HTTP_X_FORWARDED_FOR``, that means anybody can "fake" their IP address. Only
118+ use this when you can absolutely trust the value of ``HTTP_X_FORWARDED_FOR``.
119+
104120django.contrib.sessions.middleware.SessionMiddleware
105121----------------------------------------------------
106122
0 commit comments