Piwik in load balancer with multi-server issue

Hi Team,

We are facing issue using piwik with load balancer & two apache server. Installation is completed. Both piwik instance are using shared Mysql DB. If I turn off one of my web-server, I am able to login & use piwik as expected. No issues.

When both app servers are running, upon login i face issue with message: Error: You can’t access this resource as it requires an ‘view’ access for the website id = 1.

Strange thing: On trying it multiple times to login, sometime login is successfully. But again, on dashboard, some widget shows: You can’t access this resource as it requires an ‘view’ access for the website id = 1.

Below is my config settings on both the server:

assume_secure_protocol = 1
proxy_client_headers[] = "HTTP_X_FORWARDED_FOR"
salt = "xxxxxxxxxxxxxxxx"
trusted_hosts[] = "xxxx.xxxxx.com"
session_save_handler = dbtable

I have tried following things:

  1. I am using super user to login.
  2. Have configured session_save_handler = dbtable in config
    3)Also configured multi_server_environment = 1

Please guide to configure piwik on load balancer & multiple server environment. Any pointer will be of great help. Apologize if I am seeking help for common issue. Need to make it work at the earliest on production environment. Thanks.

session_save_handler should have solved it - you should check if the sessions are actually created in database.

What I would suggest you as a temporary solution is: create a subdomain of the domain the Piwik installation is under, and point it directly to ONE specific server’s IP. This will guarantee you always work against the same one server. Your UI session will be consistent on one server of the two.
If you do not want to create a subdomain, just create a record in your hosts file.

Thanks for the response. It helped us. The issue we were facing was due to absence of sticky session at load balancer level. Once the login is successfully for a given user, all subsequent request should go to the same instance of piwik.