Search code examples
phplaravelsessionload-balancingdigital-ocean

DigitalOcean Linux Ubuntu Load Balancer Laravel get 419 Page expired on login


I have 3 running DO Linux Ubuntu 20.04 droplet servers that works well with functionally login session using apache2 with Laravel 8.

When I use load balancer to this 3 droplets, it works and show the webpages well with SSL. The problem occurs when going to login (creating session) and then it will show 419 page expired.

What I have done for the 3 servers:

  1. CSRF on form
  2. chmod 775 on vendor, bootstrap cache, storage
  3. php artisan cache:clear + php artisan config:cache
  4. Using session database instead of default session files (also checked the session is stored well in the database on each droplets)

Most people with the same problem got solved by solution number 4 (database session), but it still doesn't work on my load balancer. I haven't found any other solutions so please if maybe anyone know how to solve this problem.


Solution

  • you have to use a shared db for all the droplets such as digital ocean managed service. The user session is managed with the database, so you have to "share" the info between all the droplets.

    MM