def user_real_ip(request):
    """
    Tornado is meant to be deployed behind a proxy. The official documentation says
    remote_ip is to check if a X-Real-Ip exists, but apparently that's not the case.

    :type request: tornado.web.RequestHandler.request
    :param request: HTTP Request
    """
    if "X-Real-IP" in request.headers:
        return request.headers.get("X-Real-IP")
    else:
        return request.remote_ip