Statistics
| Branch: | Tag: | Revision:

root / snf-webproject / synnefo / webproject / middleware / remoteaddr.py @ 0fa71fcc

History | View | Annotate | Download (441 Bytes)

1
class RemoteAddrMiddleware(object):
2
    """
3
    A generic middleware that sets the REMOTE_ADDR if not sent by the server.
4

5
    Solves issues with nginx deployment that don't sets the REMOTE_ADDR meta
6
    key.
7
    """
8
    def process_request(self, request):
9
        if 'REMOTE_ADDR' in request.META:
10
            request.META['REMOTE_ADDR'] = request.META.get('HTTP_X_REAL_IP',
11
                                                           None)