You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Carl Johnstone <mo...@fadetoblack.me.uk> on 2007/08/02 17:07:53 UTC

reverse proxy/logging problem

Hi,

I've got a two-apache reverse proxy setup, split over two hosts.

The problem I've got is that I'd like to put the user_id in the access logs 
so that our log analysis software can make use of it.

Setting apache->user correctly logs the user at the back-end however the IP 
addresses are wrong, being the internal address of the front-end proxy. Also 
requests dealt with purely at the front-end aren't logged.

Logging at the front-end means all requests are logged with the right IP 
address. Additional bonuses for me are that those servers are less loaded, 
and I'd be able to turn off logging at the back-end. However the user_id 
isn't available.

Is there any easy way to pass the user_id from the back-end in such a way 
the front-end could log it? Or is there another option?

Carl


Re: reverse proxy/logging problem

Posted by Torsten Foertsch <to...@gmx.net>.
On Thursday 02 August 2007 17:07, Carl Johnstone wrote:
> The problem I've got is that I'd like to put the user_id in the access logs
> so that our log analysis software can make use of it.
>
> Setting apache->user correctly logs the user at the back-end however the IP
> addresses are wrong, being the internal address of the front-end proxy.
> Also requests dealt with purely at the front-end aren't logged.
>
> Logging at the front-end means all requests are logged with the right IP
> address. Additional bonuses for me are that those servers are less loaded,
> and I'd be able to turn off logging at the back-end. However the user_id
> isn't available.
>
> Is there any easy way to pass the user_id from the back-end in such a way
> the front-end could log it? Or is there another option?

I'd try to put the user_id in a X-... output header on the backend and log it 
as "%{X-...}o" on the frontend. Maybe you can even use mod_headers to remove 
the header before it reaches the browser.

Torsten

Re: reverse proxy/logging problem

Posted by Jonathan Vanasco <jv...@2xlp.com>.
On Aug 2, 2007, at 11:07 AM, Carl Johnstone wrote:

> I've got a two-apache reverse proxy setup, split over two hosts.
>
> The problem I've got is that I'd like to put the user_id in the  
> access logs so that our log analysis software can make use of it.
>
> Setting apache->user correctly logs the user at the back-end  
> however the IP addresses are wrong, being the internal address of  
> the front-end proxy. Also requests dealt with purely at the front- 
> end aren't logged.

This should help you outright, or you can pull out code for your own use
	http://search.cpan.org/~jvanasco/Apache2-xForwardedFor-0.04/lib/ 
Apache2/xForwardedFor.pm

> Logging at the front-end means all requests are logged with the  
> right IP address. Additional bonuses for me are that those servers  
> are less loaded, and I'd be able to turn off logging at the back- 
> end. However the user_id isn't available.
>
> Is there any easy way to pass the user_id from the back-end in such  
> a way the front-end could log it? Or is there another option?

you should likely be able to roll your own based on the above.