PDA

View Full Version : Proxy Session (Squid) Hack


stilger
10-15-2002, 02:33 PM
Has anyone come up with a hack to make Vbull work properly when you are using squid for cacheing? I was thinking of trying to do something like this:

From original admin/session.php

// ###################### Start sessions #######################
// get session info
unset($bbuserinfo);
unset($session);

// get first 50 chars
$HTTP_USER_AGENT=substr($HTTP_USER_AGENT,0,50);
$REMOTE_ADDR=substr($REMOTE_ADDR,0,50);


I was thinking of changing to something like this:

// ###################### Start sessions #######################
// get session info
unset($bbuserinfo);
unset($session);

// get first 50 chars
$HTTP_USER_AGENT=substr($HTTP_USER_AGENT,0,50);
if $REMOTE_ADDR='127.0.0.1' {
$REMOTE_ADDR=substr($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'],0,50);
} else {
$REMOTE_ADDR=substr($REMOTE_ADDR,0,50);


Any help with my syntax and idea would be great.
Squid always reports 127.0.0.1 for the REMOTE_ADDR. There are times when we bypass squid so that I would not want to change it to a permanent setting. Making these changes in the functions.php or global.php would be ok by me also but I could not find what I thought was the correct spot..

Thanks for any help.

Mystikal
10-15-2002, 05:03 PM
if (getenv(HTTP_X_FORWARDED_FOR)){
$ip=getenv(HTTP_X_FORWARDED_FOR);
}
else {
$ip=getenv(REMOTE_ADDR);
}

stilger
10-15-2002, 06:04 PM
Thats the code you would use to verify if the HTTP_X_FORWARD_FOR is there and useable? Could I just suplement that code into the session code and then use $IP or whatever i call it when i do the $REMOTE_ADDR=substr($REMOTE_ADDR,0,50); part of the code or are you recommending this be put in the global or functions php files?

Thanks

spazeman
11-21-2002, 01:44 AM
yea I want to know too!! ???

Scott MacVicar
11-21-2002, 11:52 AM
if (isset($HTTP_X_FORWARDED_FOR))
{
$REMOTE_ADDR = $HTTP_X_FORWARDED_FOR;
} elseif (isset($HTTP_PROXY_USER))
{
$REMOTE_ADDR = $HTTP_PROXY_USER;
}
$REMOTE_ADDR = preg_replace('#^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.( \d{1,3})#s', '\\1.\\2.\\3.\\4', $REMOTE_ADDR);

this may be appearing in the 2.2.9 final depending what testing returns for the AOL issues that have been appearing.

stilger
11-27-2002, 06:38 PM
Vbulletin 2.2.9 is released and I do not see any mention of this in the changed files. Has this been included and if it has not what files do I need to make this change in to make this work? We are getting killed with users login in as some one else because of our forced use of squid to help with the load.

Thanks..

Originally posted by PPN
if (isset($HTTP_X_FORWARDED_FOR))
{
$REMOTE_ADDR = $HTTP_X_FORWARDED_FOR;
} elseif (isset($HTTP_PROXY_USER))
{
$REMOTE_ADDR = $HTTP_PROXY_USER;
}
$REMOTE_ADDR = preg_replace('#^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.( \d{1,3})#s', '\\1.\\2.\\3.\\4', $REMOTE_ADDR);

this may be appearing in the 2.2.9 final depending what testing returns for the AOL issues that have been appearing.

stilger
11-30-2002, 08:39 AM
Anyone have any ideas regarding my question on where exactly to add this?