X-Git-Url: https://git.mdrn.pl/fnpdjango.git/blobdiff_plain/7b2a81536977bb13b68ada3e5a281e35b24e0bfd..f22b82075d9060e0c4062315cc0f1d4401a44a3d:/fnpdjango/middleware.py?ds=sidebyside diff --git a/fnpdjango/middleware.py b/fnpdjango/middleware.py index 21de872..fcf4c36 100644 --- a/fnpdjango/middleware.py +++ b/fnpdjango/middleware.py @@ -1,15 +1,18 @@ from django.utils import translation from django.conf import settings from django.http import Http404 +from . import app_settings class SetRemoteAddrFromXRealIP(object): """Sets REMOTE_ADDR from the X-Real-IP header, as set by Nginx.""" def process_request(self, request): - try: - request.META['REMOTE_ADDR'] = request.META['HTTP_X_REAL_IP'] - except KeyError: - return None + if app_settings.REALIP: + try: + request.META['REMOTE_ADDR'] = request.META['HTTP_X_REAL_IP'] + except KeyError: + pass + return None class URLLocaleMiddleware(object):