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