1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.2 Problem with Google PageSpeed service

Discussion in 'Troubleshooting and Problems' started by Jeffin, Jul 25, 2013.

  1. Jeffin

    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
  2. Jeffin

    Jeffin Well-Known Member

    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.
  3. Mike

    Mike XenForo Developer Staff Member

    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.
    Jeffin likes this.
  4. Jeffin

    Jeffin Well-Known Member

    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:
    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
  5. Mike

    Mike XenForo Developer Staff Member

    Jeffin likes this.
  6. Jeffin

    Jeffin Well-Known Member

    Ah. Thank you. :D
  7. Jeffin

    Jeffin Well-Known Member

    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:
    # 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: Jul 26, 2013
  8. Mike

    Mike XenForo Developer Staff Member

    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:
    if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
    woody and Jeffin like this.
  9. The1LT

    The1LT Member

    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.
  10. Jeffin

    Jeffin Well-Known Member

    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.
  11. The1LT

    The1LT Member

    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.
  12. Mick West

    Mick West Well-Known Member

    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

  13. The1LT

    The1LT Member

    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.

  14. Mick West

    Mick West Well-Known Member

    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.
  15. RoldanLT

    RoldanLT Well-Known Member

    This service is the best replacement of Incapsula and Cloudfalre.
  16. Mick West

    Mick West Well-Known Member

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

    Mick West Well-Known Member

    I've now just disabled ALL the Optimize CSS settings.
    The1LT likes this.

Share This Page