You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Maurice Yarrow <ya...@best.com> on 2006/11/03 22:23:17 UTC
obtain X-Forwarded-for: client-IP-address in access logs
Hello Tomcat community
I have tomcat (5.0.28) running behind pound (2.1.3)
reverse-proxy-load-balancer.
This is a very effective setup, as I have pound also fronting apache and
mongrel-rails
clusters.
Question:
Pound adds the following to its request to backend servers:
X-Forwarded-for: client-IP-address
I would like to be able to obtain this client-IP address in the tomcat
access logs.
I tried all available formats (%a, %A, %b, %B, etc.,etc.) for the
logger pattern,
but of course, none produced the client IP address placed in the request by
Pound.
I could, of course, grep through the Pound log output which, by default,
winds
up on /var/log/messages, but would rather just be able to see this in the
tomcat access log.
How could I, say, derive my own logger class and capture this header
info that
pound places in the request to backend server ??
Is there a simpler way ? Am I unaware of a direct way to do this ?
Maurice Yarrow
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: obtain X-Forwarded-for: client-IP-address in access logs
Posted by Martin Gainty <mg...@hotmail.com>.
you can acquire the local IP (%A) and remote IP (%a) if you implement AccessLogValve
http://tomcat.apache.org/tomcat-5.0-doc/catalina/docs/api/org/apache/catalina/valves/AccessLogValve.html
M-
This e-mail communication and any attachments may contain confidential and privileged information for the use of the
designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received
this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its
contents
----- Original Message -----
From: "Maurice Yarrow" <ya...@best.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Friday, November 03, 2006 4:23 PM
Subject: obtain X-Forwarded-for: client-IP-address in access logs
> Hello Tomcat community
>
> I have tomcat (5.0.28) running behind pound (2.1.3)
> reverse-proxy-load-balancer.
>
> This is a very effective setup, as I have pound also fronting apache and
> mongrel-rails
> clusters.
>
> Question:
> Pound adds the following to its request to backend servers:
> X-Forwarded-for: client-IP-address
>
> I would like to be able to obtain this client-IP address in the tomcat
> access logs.
> I tried all available formats (%a, %A, %b, %B, etc.,etc.) for the
> logger pattern,
> but of course, none produced the client IP address placed in the request by
> Pound.
>
> I could, of course, grep through the Pound log output which, by default,
> winds
> up on /var/log/messages, but would rather just be able to see this in the
> tomcat access log.
>
> How could I, say, derive my own logger class and capture this header
> info that
> pound places in the request to backend server ??
>
> Is there a simpler way ? Am I unaware of a direct way to do this ?
>
> Maurice Yarrow
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Re: obtain X-Forwarded-for: client-IP-address in access logs
Posted by Maurice Yarrow <ya...@best.com>.
Rainer (and also, Martin)
Thanks, gentlemen.
Maurice
Rainer Jung wrote:
>... for the quotes simply use the predefined xml entity:
>
> "
>
>Maurice Yarrow schrieb:
>
>
>>Hello, again, Tomcat community:
>>
>>I found the answer to my own question below:
>>Use:
>>
>> pattern="%{X-Forwarded-for}i %l %u %t %r %s %b"
>>
>>in the access log valve config.
>>
>>Only thing: I would like to surround the %r with "%r", as
>>is done in the "common" setup.
>>What byzantine combination of single quote, double quote,
>>backslashes is required for this to be acceptable to the
>>serverl.xml XML readin ? (I tried a whole bunch of different
>>combinations but all error'ed out on startup.)
>>
>>Maurice
>>
>>
>>
>>
>>Maurice Yarrow wrote:
>>
>>
>>
>>>Hello Tomcat community
>>>
>>>I have tomcat (5.0.28) running behind pound (2.1.3)
>>>reverse-proxy-load-balancer.
>>>
>>>This is a very effective setup, as I have pound also fronting apache
>>>and mongrel-rails
>>>clusters.
>>>
>>>Question:
>>>Pound adds the following to its request to backend servers:
>>> X-Forwarded-for: client-IP-address
>>>
>>>I would like to be able to obtain this client-IP address in the tomcat
>>>access logs.
>>>I tried all available formats (%a, %A, %b, %B, etc.,etc.) for the
>>>logger pattern,
>>>but of course, none produced the client IP address placed in the
>>>request by
>>>Pound.
>>>I could, of course, grep through the Pound log output which, by
>>>default, winds
>>>up on /var/log/messages, but would rather just be able to see this in the
>>>tomcat access log.
>>>
>>>How could I, say, derive my own logger class and capture this header
>>>info that
>>>pound places in the request to backend server ??
>>>
>>>Is there a simpler way ? Am I unaware of a direct way to do this ?
>>>
>>>Maurice Yarrow
>>>
>>>
>>>---------------------------------------------------------------------
>>>To start a new topic, e-mail: users@tomcat.apache.org
>>>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>
>>---------------------------------------------------------------------
>>To start a new topic, e-mail: users@tomcat.apache.org
>>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: obtain X-Forwarded-for: client-IP-address in access logs
Posted by Rainer Jung <ra...@kippdata.de>.
... for the quotes simply use the predefined xml entity:
"
Maurice Yarrow schrieb:
> Hello, again, Tomcat community:
>
> I found the answer to my own question below:
> Use:
>
> pattern="%{X-Forwarded-for}i %l %u %t %r %s %b"
>
> in the access log valve config.
>
> Only thing: I would like to surround the %r with "%r", as
> is done in the "common" setup.
> What byzantine combination of single quote, double quote,
> backslashes is required for this to be acceptable to the
> serverl.xml XML readin ? (I tried a whole bunch of different
> combinations but all error'ed out on startup.)
>
> Maurice
>
>
>
>
> Maurice Yarrow wrote:
>
>> Hello Tomcat community
>>
>> I have tomcat (5.0.28) running behind pound (2.1.3)
>> reverse-proxy-load-balancer.
>>
>> This is a very effective setup, as I have pound also fronting apache
>> and mongrel-rails
>> clusters.
>>
>> Question:
>> Pound adds the following to its request to backend servers:
>> X-Forwarded-for: client-IP-address
>>
>> I would like to be able to obtain this client-IP address in the tomcat
>> access logs.
>> I tried all available formats (%a, %A, %b, %B, etc.,etc.) for the
>> logger pattern,
>> but of course, none produced the client IP address placed in the
>> request by
>> Pound.
>> I could, of course, grep through the Pound log output which, by
>> default, winds
>> up on /var/log/messages, but would rather just be able to see this in the
>> tomcat access log.
>>
>> How could I, say, derive my own logger class and capture this header
>> info that
>> pound places in the request to backend server ??
>>
>> Is there a simpler way ? Am I unaware of a direct way to do this ?
>>
>> Maurice Yarrow
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: obtain X-Forwarded-for: client-IP-address in access logs
Posted by Maurice Yarrow <ya...@best.com>.
Hello, again, Tomcat community:
I found the answer to my own question below:
Use:
pattern="%{X-Forwarded-for}i %l %u %t %r %s %b"
in the access log valve config.
Only thing: I would like to surround the %r with "%r", as
is done in the "common" setup.
What byzantine combination of single quote, double quote,
backslashes is required for this to be acceptable to the
serverl.xml XML readin ? (I tried a whole bunch of different
combinations but all error'ed out on startup.)
Maurice
Maurice Yarrow wrote:
> Hello Tomcat community
>
> I have tomcat (5.0.28) running behind pound (2.1.3)
> reverse-proxy-load-balancer.
>
> This is a very effective setup, as I have pound also fronting apache
> and mongrel-rails
> clusters.
>
> Question:
> Pound adds the following to its request to backend servers:
> X-Forwarded-for: client-IP-address
>
> I would like to be able to obtain this client-IP address in the tomcat
> access logs.
> I tried all available formats (%a, %A, %b, %B, etc.,etc.) for the
> logger pattern,
> but of course, none produced the client IP address placed in the
> request by
> Pound.
> I could, of course, grep through the Pound log output which, by
> default, winds
> up on /var/log/messages, but would rather just be able to see this in the
> tomcat access log.
>
> How could I, say, derive my own logger class and capture this header
> info that
> pound places in the request to backend server ??
>
> Is there a simpler way ? Am I unaware of a direct way to do this ?
>
> Maurice Yarrow
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org