public static String getRemoteAddress(HttpServletRequest request) {
    String ip = null;
    for (String header : headersToCheck) {
      ip = request.getHeader(header);
      if (!isRemoteAddressUnknown(ip)) {
        break;
      }
    }
    if (isRemoteAddressUnknown(ip)) {
      ip = request.getRemoteAddr();
    }
    if (containsMultipleRemoteAddresses(ip)) {
       ip = ip.substring(0, ip.indexOf(","));
    }
    return ip;
  }
Returns remote address
@param request contains the details of http request
@return
ambari-server/src/main/java/org/apache/ambari/server/utils/RequestUtils.java