tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Brittain <>
Subject Re: access log and Apache server
Date Thu, 17 Sep 2009 19:06:02 GMT
Hi Angelo.

I'm assuming you're using mod_proxy_http (you said port 80).  If so, then
there is indeed a way to make this work.

In your Apache HTTPD config, where you're configuring proxying the request,
make sure you add:

ProxyVia On

That will make HTTPD set the "x-forwarded-for" HTTP request header's value
to the IP address of the client.  This is passed to Tomcat when HTTPD
proxies the request.

Then, where you're configuring the AccessLogValve (usually in your
conf/server.xml file), change the default logging pattern to log the
"x-forwarded-for" header value, like this:

<Host ...>
    <Valve className="org.apache.catalina.valves.AccessLogValve"
           pattern="%{x-forwarded-for}i %l %u %t %r %s %b"

With that configuration, AccessLogValve will log the x-forwarded-for header
value that is set by Apache HTTPD's mod_proxy, and the remainder of the
logging pattern will be the same as usual.

Jason Brittain

On Thu, Sep 17, 2009 at 6:01 AM, Angelo Chen <>wrote:

> Hi,
> I run tomcat behind an Apache server, Apache will proxy to tomcat from port
> 80, this works quite well, but the access log in tomcat shows only
>, not the real IP:
> - - [17/Sep/2009:08:51:21 -0400] "POST /sendmsg HTTP/1.1" 302 -
> any idea how to have real IP in the log?
> Thanks,
> --
> View this message in context:
> Sent from the Tomcat - User mailing list archive at
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message