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.
>
> Any help appreciated.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>   
What about just implementing this as a filter and then construct a
request wrapper in the filter to read that header and override the
getRemoteAddr() method.

--David

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to