tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henri Gomez <henri.go...@gmail.com>
Subject Re: RemoteIpValve advices
Date Mon, 24 Jan 2011 14:23:09 GMT
> x-forwarded-proto is already handled.

Exact.

> x-forwarded-host is non-trivial since the mapping is done before the
> valve is invoked. Simpler to do the equivalent of ProxyPreserveHost On
> in the proxy.
>
> x-forwarded-port is not handled directly but x-forwarded-proto does set
> the port based on the protocol.
>
>> The fix should be easy and I could even provide the required patch.
>
> I'm not so sure it is that easy.

I've got a very basic valve for now to handle this kind of X-Forwarded
situation :


public class ForwardedValve extends ValveBase {

    public void invoke(Request paramRequest, Response paramResponse)
            throws IOException, ServletException {

        String header = paramRequest.getHeader("X-Forwarded-Host");

        if (header != null)
            paramRequest.setServerName(header);

        int header1 = paramRequest.getIntHeader("X-Forwarded-Port");

        if (header1 > 0)
            paramRequest.setServerPort(header1);

        getNext().invoke(paramRequest, paramResponse);
    }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message