Page 1 of 1

Suggestion: Optionally log X-Forwarded-For

Posted: Sat Feb 18, 2006 5:55 pm
by Zugschlus
Hi,

the apache that runs my s9y is located behind a reverse proxy. It therefore logs all access as originating from 127.0.0.1.

I would like to have an option making s9y log the IP addresses given in the X-Forwarded-For-Header of the http request instead or additional to the client IP address. Statistics should use the address from X-Forwarded-For as default, falling back to client IP if that header is not present.

Re: Suggestion: Optionally log X-Forwarded-For

Posted: Sat Feb 18, 2006 5:59 pm
by garvinhicking
You should be able to easily get this by replacing "REMOTE_ADDR" with "X_FORWARDED_FOR" in the source code, right?

I have never used any reverse proxy, so I know nothing about that stuff.

Regards,
Garvin

Re: Suggestion: Optionally log X-Forwarded-For

Posted: Sat Feb 18, 2006 6:04 pm
by Zugschlus
garvinhicking wrote:You should be able to easily get this by replacing "REMOTE_ADDR" with "X_FORWARDED_FOR" in the source code, right?
I don't know enough about php to comment about this, but the final code should probably have something like "if defined X_FORWARDED_FOR { return X_FORWARDED_FOR } else { return REMOTE_ADDR }"

Otherwise, for examples, all comments and trackback show up as being made from the IP address of the reverse proxy, which makes spam filters ineffective.

Re: Suggestion: Optionally log X-Forwarded-For

Posted: Sat Feb 18, 2006 6:14 pm
by garvinhicking
Please try to replace all "REMOTE_ADDR" in your serendipity files with "X_FORWARDED_FOR" on a global replace (case sensitive). I have no possibilities to check if this works; if it does, I can include a more verbose patch that will first check if X_FORWARDED_FOR is set.

Regards,
Garvin