You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by semo ksar <ch...@yahoo.com> on 2006/07/10 16:56:20 UTC
Client IP address when Apache is a proxy
Hello,
I am trying to retrieve the client IP address
accessing the web
services. Because Apache is our proxy for all
requests, when I try to
retrieve the client IP I always get the localhost IP:
127.0.0.1
The following code returns the localhost IP:
MessageContext msgContext =
MessageContext.getCurrentContext();
if(msgContext != null) {
return
msgContext.getProperty(Constants.MC_REMOTE_ADDR).toString();
}
return "Unknown";
From a servlet, obtaining the client IP address can
be achieved using
this code.
String ipAddress =
request.getHeader("x-forwarded-for");
if (ipAddress == null) {
ipAddress =
request.getHeader("X_FORWARDED_FOR");
if (ipAddress == null){
ipAddress = request.getRemoteAddr();
}
}
return IPaddress ;
Any help is greatly appreciated.
Thank you very much
P.S This is a re-post of the same message since I did
not get any replies --Sorry if this is causes any inconvenience
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org