def reverseProxyProtocolCorrection(event):
    event.request.scheme = 'https' if event.request.headers['X-Forwarded-Proto'
        ] == 'https' else 'http'
event.request.remote_addr = parseXForward(event.request.headers[
    'X-Forwarded-For'], event.request.remote_addr)
How to get the real IP of a client in a pyramid server behind a nginx proxy