Java????????????IP???
???????????? ???????[ 2015/3/26 14:41:42 ] ????????Java ??????? ??????
??????JSP???????????IP???????????request.getRemoteAddr()????????????????????????Ч??????????????Apache??Squid????????????????????????????IP????????????????????iisforward???ISAPI??????????request??????????????????ЩWLS??????????????????£??????request.getRemoteAddr()????????????????IP???
?????????????????????????http://192.168.1.110??2046/??URL????????http://www.javapeixun.com.cn/??URL?????request.getRemoteAddr?????????????IP??????127.0.0.1??192.168.1.110??????????????????IP??
???????????????????????????????????????м?????????????????????????IP??????????????????????????????????????????????????????????HTTP?????У???????X??FORWARDED??FOR??????????????е?????IP?????????????????????????????????????http://www.javapeixun.com.cn/index.jsp/????????????????????????????????????????index.jsp??????????????????????????http://192.168.1.110??2046/index.jsp??????????????????????????????????????????????????????????index.jsp???????index.jsp?????request.getRemoteAddr??????????????IP????????????????????????????????IP?????
????????iisforward????????£?
????1 WL-Proxy-Client-IP=211.161.1.239
????2 Proxy-Client-IP=211.161.1.239
????3 X-Forwarded-For=211.161.1.239
????4 WL-Proxy-Client-Keysize=
????5 WL-Proxy-Client-Secretkeysize=
????6 X-WebLogic-Request-ClusterInfo=true
????7 X-WebLogic-KeepAliveSecs=30
????8 X-WebLogic-Force-JVMID=-327089098
????9 WL-Proxy-SSL=false
????????????
?????????????????????IP???????????£?
????
???????????
????1 private String getIpAddress(HttpServletRequest request){
????2 String ipAddress=null;
????3 ipAddress=request.getHeader("x-forwarded-for");
????4 if(ipAddress==null||ipAddress.length()==0||"unknown".equalsIgnoreCase(ipAddress)){
????5 ipAddress=request.getHeader("Proxy-Client-IP");
????6}
????7 if(ipAddress==null||ipAddress.length()==0||"unknown".equalsIgnoreCase(ipAddress)){
????8 ipAddress=request.getHeader("WL-Proxy-Client-IP");
????9}
????10 if(ipAddress==null||ipAddress.length()==0||"unknown".equalsIgnoreCase(ipAddress)){
????11 ipAddress=request.getRemoteAddr();
????12 if(ipAddress.equals("127.0.0.1")){
????13//??????????????????IP
????14 InetAddress inet=null;
????15 try{
????16 inet=InetAddress.getLocalHost();
????17}catch(UnknownHostException e){
????18 e.printStackTrace();
????19}
????20 ipAddress=inet.getHostAddress();
????21}
????22}
????23//?????????????????????????IP?????????IP?????IP????'??'???
????24 if(ipAddress!=null&&ipAddress.length()>15){//"***.***.***.***".length()=15
????25 if(ipAddress.indexOf("??")>0){
????26 ipAddress=ipAddress.substring(0??ipAddress.indexOf("??"));
????27}
????28}
????29 return ipAddress;
????30}
?????????????????????x-forwarded-for????????????????????IP??????????????£?x-forwarded-for?е???????unknown????ЧIP????????IP??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11