XF 1.4 Obvious Errors since moving to load balanced Systems

freakathome

New member
Hi there,

a few days ago we moved to a load balanced system. We have got one load balancer (Apache2, Proxypass) and two web nodes. The two webnodes are configured in php.ini to use the same memcached server for sessions.

Now we got the following problem: If you login to the Admin Area, the site is going to reload (empty fields). If you press [F5] after that, you'll be logged in. Same in logging out from the forum, the site reloads but you aren't finally logged out by the system.

Our Cache / Session Settings in library/config.php are configured as follows:
Code:
$config['cache']['cacheSessions'] = true;
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions']['cache_id_prefix'] = 'xf_';

$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
'compression' => false,
'servers' => array(
  array(
   // your memcached server IP /address
   'host' => '10.11.12.10',

   // memcached port
   'port' => 11211,
  )
)
);

$config['cookie'] = array(
        'prefix' => 'xemforo_lp_',
        'path' => '/',
        'domain' => ''
);

Can you help us?
Its very critical. I haven't worked with Xenforo before, so it isn't easy for me. I spended a few hours finding the mistake - without a solution.

Thank you!
 
If they're pointing at the same Memcached server, then there's no reason for sessions to not stick. I'd start by disabling the cache to take that out as a variable.

However, it does sound like there's some element of caching going on. Logging out should be deleting/overwriting cookies on the client, which would mean that your previous session would no longer be available even if session "consistency" was lacking. I'd check your reverse proxy settings.

Somewhat relevant as well is that you will want to make sure that XF is getting the correct IP via REMOTE_ADDR. You can handle this with a web server extension (something like mod_rpaf) or within XF's config.php to overwrite $_SERVER['REMOTE_ADDR'] with the value from the forwarded header.
 
I'd start by disabling the cache to take that out as a variable.
We already tried to disable this cache settings, same result.

However, it does sound like there's some element of caching going on.
Yes, i think so too.

I'd check your reverse proxy settings.
Should i post the Configuration of the Balancer Apache2?

make sure that XF is getting the correct IP via REMOTE_ADDR
We included mod_rpaf before, so the Webnodes finally got the right IP on $_SERVER[REMOTE_ADDR].
 
Last edited:
As far as I've read, ProxyPass doesn't do any caching on its own, though it can be configured to work with mod_cache. I'd look into mod_cache settings.

In terms of testing, I'd probably test 2 scenarios:
  1. Make sure it works when correctly when accessing the application server directly.
  2. Access the load balancer but take one of the app servers out of the rotation so you know you're always hitting one of them.
What happens there may influence the troubleshooting approach, though I would note that I know we have multiple customers running in a load balanced environment and I haven't heard of issues such as this from them.
 
  • Like
Reactions: HWS
Hi Mike,

As far as I've read, ProxyPass doesn't do any caching on its own, though it can be configured to work with mod_cache. I'd look into mod_cache settings.

We doesn't do any kind of caching on the ProxyPass Machine.
Here is the Configuration of the Balancer Apache2, but in case of your two test szenarios i think the problem is going on another reason.
Code:
<VirtualHost *:80>
        ServerName xxxxx.de
        ServerAlias www.xxxxx.de xxx.xxx.xxx.xxx
        DocumentRoot /var/www/
        ProxyRequests Off
        ErrorDocument 503 /error_documents/503.html

        <Proxy *>
          Order deny,allow
          Allow from all
        </Proxy>

        ProxyPass /error_documents !
        ProxyPass /control-balancer !
        ProxyPass / balancer://lpdecluster/ nofailover=On
        ProxyPassReverse / http://10.11.12.3/
        ProxyPassReverse / http://10.11.12.4/

        <Proxy balancer://lpdecluster>
          BalancerMember http://10.11.12.3
          BalancerMember http://10.11.12.4
          ProxySet lbmethod=bybusyness
        </Proxy>

        <Location /control-balancer>
          SetHandler balancer-manager

          Order deny,allow
          Deny from all
        </Location>
</VirtualHost>


Make sure it works when correctly when accessing the application server directly.

I gave one webnode a IP Adress, so i can load it from outside.
Same issues here, it doesn't work.

Access the load balancer but take one of the app servers out of the rotation so you know you're always hitting one of them.

We got the same errors as before, i deactivated one of the two webnodes to only jump on / visit one at this test time. Same result.
 
I think i got it working now.

I activated mod_cache on both machines
Code:
a2enmod cache

and after that i added this to the .htaccess in xenforo path
Code:
Header set Expires "Thu, 19 Nov 1981 08:52:00 GM"
Header set Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
Header set Pragma "no-cache"

EDIT:
Okay, we got now some issues with Plugins, using cache systems.
Do you got a solution for that?
 
Last edited:
I would note that we send some of those headers by default. They should be enough to stop subsequent requests from using them.
Code:
header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
header('Cache-control: private, max-age=0');
They're not as aggressive though. (The headers listed in your post would prevent the back button from serving a cached page.) But if it works for you...

I'm unsure what you're referring to with your edit.
 
Top Bottom