Elli Albek wrote:
> Hi,
> We have Tomcat behind a load balancer. The servlet API and tomcat libraries
> see the load balancer IP as the client IP.
>
> I tried to write a simple valve which will extract the IP from HTTP header
> X-Forwarded-For
> and continue the valve chain using this IP as the client IP. This will be
> the first valve in the chain, so everything will work as normal afterwards
> including log files, IP filter valve, etc.
>
> The problem I am facing, is when I try to set the remote IP on the request
> from my valve, the code does nothing. This is the set method in the class
> org.apache.catalina.connector.Request:
>
> public void setRemoteAddr(String remoteAddr) {
> // Not used
> }
>
> The variable is protected so I cannot access it directly from my code.
>
> Is there any way to implement this Valve?
>
> Is there anything already shipped in tomcat to extract the client IP from
> the header?
>
> I DO NOT want to write a servlet filter for various reasons, so I hope there
> is a way to do it with a valve.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47330 is on the todo
list but my current plan is to implement it as a Filter rather than a valve.
What is the issue with using a Filter?
If you really want to write a filter than that bug report should be all
you need.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]