獲取傳送請求的ip位址 客戶端位址

2021-09-26 08:49:58 字數 1213 閱讀 1589

* 獲取傳送請求的位址ip

* @param request

* @return

*/public static string getip()  

if(ipaddress == null || ipaddress.length() == 0 || "unknown".equalsignorecase(ipaddress))  

if (ipaddress == null || ipaddress.length() == 0 || "unknown".equalsignorecase(ipaddress))  

if (ipaddress == null || ipaddress.length() == 0 || "unknown".equalsignorecase(ipaddress))  

if (ipaddress == null || ipaddress.length() == 0 || "unknown".equalsignorecase(ipaddress))

if(ipaddress == null || ipaddress.length() == 0 || "unknown".equalsignorecase(ipaddress)) catch (unknownhostexception e)  

ipaddress= inet.gethostaddress();  

}  }  

//對於通過多個**的情況,第乙個ip為客戶端真實ip,多個ip按照','分割  

if(ipaddress!=null && ipaddress.length()>15)  

}  return ipaddress;   

}catch (exception e)

}location /

$proxy_add_x_forwarded_for 這個變數和remote_addr的區別是

proxy_add_x_forwarded_for會將經過的所有**ip相加起來,

remote_addr則只是獲取到直接連線到nginx的ip位址

獲取客戶端IP位址

title generating test data author wufeng4552 date 2009 09 23 10 34 02 功能 獲客戶 ip位址 if object id getclientip isnot null drop proc getclientip go create ...

客戶端獲取IP位址

string ip request.getheader x forwarded for string regex 2 0 4 d 25 0 5 01 d d?2 0 4 d 25 0 5 01 d d?if ip null ip.length 0 ip.equalsignorecase locali...

servlet如何獲取請求客戶端的IP位址

但是request.getremoteaddr 這種方法在大部分情況下都是有效的。但是在通過了apache,squid等反向 軟體就不能獲取到客戶端的真實ip位址了。如果使用了反向 軟體,將的url反向 為的url時,用request.getremoteaddr 方法獲取的ip位址是 127.0.0...