XF 1.2 Problem with Google PageSpeed service

Jeffin

Well-known member
Currently I am using Google's own CDN service called Google PageSpeed service. I have changed my DNS to point to their servers and now they are serving my pages from their server. It's faster now.

The problem now is that I get logged out in the forum as soon as I log in which means after I log in , the logged in page is not being served to me. That problem can only be solved by checking the keeping the 'Stay logged in' box checked. I don't know how to solve this issue.

They gave me the below instruction of which the mod_rpaf plugin was installed by my hosting provider. I don't know how to do the rest of it. Can someone help me with this? Thank you.
  • (Required) Server Software: The following server systems are responsible for managing incoming connections to your origin server.
  • Apache: Install the mod_rpaf plugin.
  • Nginx: Install the ngx_http_realip_module plugin.
  • IIS: Install the Application Request Routing (ARR) module. After installing ARR, please use the HttpContext.Current.Request.Headers["X-Forwarded-For"] variable.
  • (Recommended) Server Scripting Language: To maintain full functionality of your existing site, we recommend using the following server variables to extract the original client's IP address in your code.
  • PHP: Use the server variable $_SERVER['HTTP_X_FORWARDED_FOR'].
  • ASP: Use the variable Request.ServerVariables("HTTP_X_FORWARDED_FOR").
  • (Recommended) Content Management Systems: If you are also using a content management system, we recommend making the following changes, in addition to the ones above.
  • Wordpress: Install the Reverse-Proxy Comment IP Fix plugin
  • phpBB: Turn off Session IP validation checks in the Admin->General->Server Configuration->Security Settings and turn ON the VALIDATE X_FORWARDED_FOR HEADER as described in the phpBB documentation.
Source: https://developers.google.com/speed/docs/pss/faq#clientip
 
Anybody knowledgeable about this issue? I was told by PageSpeed team that I have to contact the forum developers regarding this issue. Wordpress has a plugin to fix it and so does phpBB. Do we have a solution here as well? :unsure: Sorry for bumping the topic.
 
You can do $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR']; in config.php, but mod_rpaf really should be what's configured as it's then used at the Apache level. The config.php change won't help Apache logs, etc.
 
You can do $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR']; in config.php, but mod_rpaf really should be what's configured as it's then used at the Apache level. The config.php change won't help Apache logs, etc.

Hi Mike,

I got my hosting provider to install mod_rpaf it.

and now I added the like to my config.php and it looks like below:
$config['db']['host'] = 'xxxxxxx';
$config['db']['port'] = 'xxxxx';
$config['db']['username'] = 'xxxx_xxxx';
$config['db']['password'] = 'xxxxxxxxxxxxx';
$config['db']['dbname'] = 'xxxx_xxxxx';

$config['superAdmins'] = 'x,x';

$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR']

Did you mean I still have to configure mod_rpaf as per my site requirement? If yes, would you know what may need to be done exactly so I still my hosting provider this?

I know this is not fully xf related but I really wanted someone's help. Thank you for helping.

Update: adding the above line gave this error: Parse error: syntax error, unexpected end of file in /home/xxx/public_html/library/config.php on line 11
 
Hi @Mike, I just noticed that after adding $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR']; to config.php, I can only view my forum if I add www. to my domain name. Previously that wasn't the case. Now christianforumsite.com (without the preceding www.) throws the error "An unexpected error occurred. Please try again later".

I have temporarily solved it by adding below code to .htaccess:
Code:
# Redirecting non-www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Why would $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR']; cause this issue? Did I miss something? Need help please.
 
Last edited:
This code assumes that you're always accessing through the Google service and that the header will always be present. If you don't have the www there, then you're not serving that through Google. I should note that technically you're opening yourself up to some IP spoofing if you can't guarantee that the X-Forwarded-For header is being set only by a trusted source.

You can change the code to this:
Code:
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
    $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
 
Did you manage to get this working in the end?

I set up page speed this morning and it is indeed quicker but I've got all sorts of glitches going on now. My skin/layout doesn't render as it did before, pop menus being larger/smaller, images being in different locations etc.

Also have got the server logging in / out issue you mentioned above.
 
Did you manage to get this working in the end?

I set up page speed this morning and it is indeed quicker but I've got all sorts of glitches going on now. My skin/layout doesn't render as it did before, pop menus being larger/smaller, images being in different locations etc.

Also have got the server logging in / out issue you mentioned above.

I did get it to work and it did make some difference to download speed. But I had issues such as the one you are having one. It is difficult to update my styles because then I have to flush cache etc to get the copy on Google's server updated. I finally stopped using PageSpeed. I still have Mod_PageSpeed installed.
 
Yeah, same experience, I've updated mine back to my normal server but I sent an email to the page speed guys to report the issue so will be interested to see if they are able to make any suggestions.

Doesn't make a great deal of sense to me why using it would mess up elements of the layout but it's a pitty because there is a nice speed increase with it.

Maybe it will get better as it matures.
 
To fix the messed up layout with Google Pagespeed in Xenforo, you need to disable Combine CSS and Combine Javascript. I also disable it entirely for the /login and /admin

upload_2013-9-17_9-44-59.webp
 
Yeah I did plenty of experiments myself and came to a similar set up.

The issue I had which eventually led to turning it off was that for whatever reason if I tried to upload files larger than a certain size with page speed turned on they would just hang. I switched off the flash animation and spent hours messing with page speed but couldn't suss it in the end.

You get the same issue? Usually happened if I uploaded more than a meg or so to a post with the standard upload file option.

By hang I mean, it would run through the timer bit to show it was uploading and then get stuck at 100% and not attach it to the post correctly.

Ross
 
Actually I'm still having some issues, and my suggested fixes above might not actually be fixes. Possibly just flushing a cache somewhere, as the problem seemingly returned after a while.
 
Yeah I did plenty of experiments myself and came to a similar set up.

The issue I had which eventually led to turning it off was that for whatever reason if I tried to upload files larger than a certain size with page speed turned on they would just hang. I switched off the flash animation and spent hours messing with page speed but couldn't suss it in the end.

You get the same issue? Usually happened if I uploaded more than a meg or so to a post with the standard upload file option.

By hang I mean, it would run through the timer bit to show it was uploading and then get stuck at 100% and not attach it to the post correctly.

Ross

I don't seem to be having any problems uploading 6MB image files. Although I'm not getting a progress bar.
 
Top Bottom