![]() |
|
首页│注册│帮助 | |||
相关问题
| • | 颠峰对决:Google pk Apache, |
| • | 在Slaris10系统下编译安装apac |
| • | Apache2+php4.3.6+MySQL4.0.20 |
| • | 如何保护Linux系统下的Apache网 |
| • | Beehive应用开发详解 |
| • | Apache CXF 在 WebLogic 9.2 上 |
| • | 利用Apache实现weblogic集群配 |
| • | 开源SCA实现Apache Tuscany走向 |
待解决
在apache+Weblogic整合系统中,apache会对request对象进行再包装,附加一些WLS要用的头信息。这种情况下,直接用request.getRemoteAddr()是无法取到真正的客户IP的。
apache会增加下列头信息:
X-Forwarded-For=211.161.1.239
WL-Proxy-Client-IP=211.161.1.239
所取得客户的IP需要这样:
String ip=request.getHeader(\"X-Forwarded-For\");
if(ip == null || ip.length() == 0) {
ip=request.getHeader(\"WL-Proxy-Client-IP\");
}
if(ip == null || ip.length() == 0) {
ip=request.getRemoteAddr();
}
或者也可通过weblogic的设置直接能过request.getRemoteAddr();取得客户的IP。
在weblogic console
domain->servers->servername->General ->Advanced Options ->
WebLogic Plug-In Enabled
Specifies whether this server uses the proprietary WL-Proxy-Client-IP header. (This is needed only when WebLogic plugins are configured.)
但是如果apache设置的是反向代理这样就不行了,因为apache不会向heaer写入WL-Proxy-Client-IP的信息。只能通过第一种方法解决。
提问者: 03-16 20:08
答复
路过,帮顶
回答者:玉米づ冰冻可乐 -
2007-05-12

