Hi all,

I'm making some modifications to a largeish open source Servlet based Java web 
site that makes use of Restlet.  I'm not familiar with Restlets so I'll ask 
forgiveness in advance for any ignorance on my part. 

We are using Tomcat as the servlet container.  The rest services are configured 
by a Router inside a org.restlet.Application derived class.  One of our rest 
endpoints is served by a FileList class.  In FileList (derived from 
org.restlet.Resource) I need to get access to the client's IP address for some 
special logging we need to do there.  

Inside the FileList class I use 
this.getRequest().getClientInfo().getAddresses() to get the IP address.  
Because this application is a component of a larger site, our tomcat server is 
behind a HTTP Proxy.  That means that when we call getAddresses() I'm only 
getting the address of the proxy server.  From reading the docs, I think that I 
need to enable the useForwardedForHeader option so that the getAddresses will 
also list the address included in the X-Forwarded-For header by our proxy 
server.

I understand that if I was running this as a stand-alone Restlet server I could 
do this:

Server server = new Server(new Context(), Protocol.HTTP, 8182, restlet);
server.getContext().getParameters().add("useForwardedForHeader", "true");
server.start();

That would make Restlet pay attention to the X-Forwarded-For header, but since 
my restlet classes are embedded inside another server we aren't (that I know 
of) directly creating a org.restlet.Server.

Can anyone give me some ideas on how to configure our restlet implementaiton to 
return the real client IP address inside my org.restlet.Resource class?  I 
expect there must be some way to enable that option even though we are not 
using a stand alone server, right?

Thanks,
-Al

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2788153

Reply via email to