Gossamer Forum
Home : Products : Gossamer Forum : Development, Plugins and Globals :

setting REMOTE_ADDR = HTTP_X_FORWARDED_FOR

Quote Reply
setting REMOTE_ADDR = HTTP_X_FORWARDED_FOR
Hi,

I use a 2-apache server setup. Static docs are on a "lite" build of apache. mod_perl apps get forwarded to a "heavy" build of apache via mod_proxy. (I set it up according to this: http://modperlbook.org/html/ch12_03.html)

My problem is that REMOTE_ADDR is being set to 127.0.0.1 instead of the users actual ip address. The correct ip is in the env variable X_FORWARDED_FOR.

Is there a hook I can add to set REMOTE_ADDR equal to X_FORWARDED_FOR? This would have to happen before the forum makes any use of the REMOTE_ADDR variable. I just don't know where that would be.

Last edited by:

xev: Jun 16, 2005, 8:16 AM
Quote Reply
Re: [xev] setting REMOTE_ADDR = HTTP_X_FORWARDED_FOR In reply to
looks like I'll answer my own post lol.

I got it to work by creating a "main" hook that simply had the line:

$ENV{REMOTE_ADDR} = $ENV{HTTP_X_FORWARDED_FOR};
Quote Reply
Re: [xev] setting REMOTE_ADDR = HTTP_X_FORWARDED_FOR In reply to
Hi,

Got an anti-DDoS router by any chance? <G>

We had a similar problem. Basically, you can change the REMOTE_ADDR value to HTTP_X_FORWARDED_FOR in one of the Apache config files (Alex @ GT did this for us, so I'm afraid I don't know the gorey details +)).

Hope that helps Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] setting REMOTE_ADDR = HTTP_X_FORWARDED_FOR In reply to
You might want to take a look at mod_rpaf-2.0

It's similar to mod_proxy_forward, except with mod_rpaf, you just put it on the backend server and nothing needs to be changed on the front end.