in manager/general/src/main/java/org/apache/doris/stack/service/user/AuthenticationService.java [178:212]
private String getIpAdrress(HttpServletRequest request) {
String realIP = request.getHeader("X-Real-IP");
String xForIP = request.getHeader("X-Forwarded-For");
if (StringUtils.isNotEmpty(xForIP) && !"unKnown".equalsIgnoreCase(xForIP)) {
//After multiple reverse proxies, there will be multiple IP values,
// and the first IP is the real IP ,X-Forwarded-For: client, proxy1, proxy2,proxy
int index = xForIP.indexOf(",");
if (index != -1) {
return xForIP.substring(0, index);
} else {
return xForIP;
}
}
xForIP = realIP;
if (StringUtils.isNotEmpty(xForIP) && !"unKnown".equalsIgnoreCase(xForIP)) {
return xForIP;
}
if (StringUtils.isBlank(xForIP) || "unknown".equalsIgnoreCase(xForIP)) {
xForIP = request.getHeader("Proxy-Client-IP");
}
if (StringUtils.isBlank(xForIP) || "unknown".equalsIgnoreCase(xForIP)) {
xForIP = request.getHeader("WL-Proxy-Client-IP");
}
if (StringUtils.isBlank(xForIP) || "unknown".equalsIgnoreCase(xForIP)) {
xForIP = request.getHeader("HTTP_CLIENT_IP");
}
if (StringUtils.isBlank(xForIP) || "unknown".equalsIgnoreCase(xForIP)) {
xForIP = request.getHeader("HTTP_X_FORWARDED_FOR");
}
// Finally, the IP address is obtained through request. Getremoteaddr()
if (StringUtils.isBlank(xForIP) || "unknown".equalsIgnoreCase(xForIP)) {
xForIP = request.getRemoteAddr();
}
return xForIP;
}