服务端打印请求者的ip
https://blog.csdn.net/qq_42405688/article/details/122225412
/*** 从HTTP请求中获取客户IP地址** @param request http请求* @return 客户IP地址*/public static String getIPAddress( HttpServletRequest request ){String ip = null;String header = request.getHeader("x-forwarded-for");String[] split = null;if (header != null) {split = header.split(",");}if (split != null && split.length >= 2) {ip = split[1];}if ( ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase( ip ) ){ip = request.getHeader( "Proxy-Client-IP" );}if ( ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase( ip ) ){ip = request.getHeader( "WL-Proxy-Client-IP" );}if ( ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase( ip ) ){ip = request.getHeader( "HTTP_CLIENT_IP" );}if ( ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase( ip ) ){ip = request.getHeader( "HTTP_X_FORWARDED_FOR" );}if ( ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase( ip ) ){ip = request.getRemoteAddr();}return ip;}
https://imququ.com/post/x-forwarded-for-header-in-http.html
https://blog.csdn.net/qq_38296051/article/details/105746519
HTTP 请求头中的 X-Forwarded-For:
X-Forwarded-For: client1, proxy1, proxy2
X-Forwarded-For 包含多个IP地址,每个值通过逗号、空格分开,
最左边(client1)是最原始客户端的IP地址,中间如果有多层代理,每一层代理会将连接它的客户端IP追加在X-Forwarded-For右边