fix
[fnpdjango.git] / fnpdjango / middleware.py
1 from django.utils.deprecation import MiddlewareMixin
2 from . import app_settings
3
4
5 class SetRemoteAddrFromXRealIP(MiddlewareMixin):
6     """Sets REMOTE_ADDR from the X-Real-IP header, as set by Nginx."""
7     def process_request(self, request):
8         if app_settings.REALIP:
9             try:
10                 request.META['REMOTE_ADDR'] = request.META['HTTP_X_REAL_IP']
11             except KeyError:
12                 pass
13         return None