1 from django.utils.deprecation import MiddlewareMixin
2 from . import app_settings
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:
10 request.META['REMOTE_ADDR'] = request.META['HTTP_X_REAL_IP']