java获取当前网络IP地址 1/**2* 获取当前网络ip3*4*@paramrequest5*@return6*/7@RequestMapping("getIpAddress")8publicstaticString getIpAddress(HttpServletRequest request) {9String ip = request.getHeader("x-forwarded-for");10if(ip ==null|| ip.length() == 0 || "unknown".equalsIgnoreCase(ip...
ipAddress= ipAddress.substring(0,ipAddress.indexOf(",")); } }returnipAddress; } 2. Nginx反向代理后获取客户端请求的真实IP 在nginx.conf配置文件中,配置: proxy_set_header X-Real-IP $remote_addr; 例如: location /服务名称 { proxy_set_header X-Real-IP$remote_addr; proxy_pass http://xase...
ipAddress = ipAddress.substring(0,ipAddress.indexOf(",")); } } return ipAddress; } 2. Nginx反向代理后获取客户端请求的真实IP 在nginx.conf配置文件中,配置: proxy_set_header X-Real-IP $remote_addr; 例如: location /服务名称 { proxy_set_header X-Real-IP $remote_addr; proxy_pass http:/...
ipAddress= ipAddress.substring(0,ipAddress.indexOf(",")); } }returnipAddress; } 2. Nginx反向代理后获取客户端请求的真实IP 在nginx.conf配置文件中,配置: proxy_set_header X-Real-IP $remote_addr; 例如: location /服务名称 { proxy_set_header X-Real-IP$remote_addr; proxy_pass http://xase...