Ashraam's avatar
Level 41

Load balancer and CSRF Token exception

I am testing an infrastructure for a web application which include a load balancer, a database server and 2 web servers. All the server are on the same datacenter (provided by Digital Ocean) The redis server is a managed database product from DO too.

I'm using laravel 6.6.

The load balancer works well (using the Round Robin algorithm), but when I try to login, I always got 419 page exception.

Here is the detail of my env file

BROADCAST_DRIVER=log
CACHE_DRIVER=redis
QUEUE_CONNECTION=sync
SESSION_DRIVER=redis
SESSION_LIFETIME=120

I am using redis to share the session, but it's not working. I can read and write to the redis cluster.

When I go on a specific web server I can login without any problem.

Someone has an idea to solve this issue ? Tell me if you want more informations

Thanks

0 likes
4 replies
jlrdw's avatar

Double check and make sure the session is shared between the servers.

Ashraam's avatar
Ashraam
OP
Best Answer
Level 41

Well, I found out after hour for almost nothing, my APP_NAME was different on Server 1 and Server 2, so there was two different sessions.... :/

I found out while watch the headers in the inspect console !

2 likes
jlrdw's avatar

Well, glad you got it solved.

Please or to participate in this conversation.