I have 2 web platforms built with Laravel that work perfectly fine both on the development environment as well as on local environemnt.
The problem lies in the fact that after I deploy these applications on a cloud infrastructure as a service provider, the applications work for approximatelly ~ 1 / 2 hours, sometimes even less, and then, on every login request it redirects me to back to the login page, even though the credentials on the login attempt are correct.
In between the login request and the redirect response I get blank view with the XSRF token stored in the session, but only for a few miliseconds.
For a clearer view of the problem I need to give you the full context so I will briefly document the infrastructure and the architecture on which the application runs
The applications use the following technologies:
- Laravel (web platform built in the old fashioned monolith style) v10
- MariaDB v10.7.5
- Redis cache database v.6.2.7
- Melisearch v0.27.2
For each one of these technologies there is a Docker container. The communication between them is facilitated by a traefik Docker network. The applications works as in the following diagram:
These are some of the environment configuration variables I use that I think might be relevant for the problem:
- for one of the platforms are these:
CACHE_DRIVER: "redis"
QUEUE_CONNECTION: "redis"
SESSION_DRIVER: "redis"
- for the other platfom are just the default ones:
CACHE_DRIVER: "file"
QUEUE_CONNECTION: "sync"
SESSION_DRIVER: "file"
The following things can be done to temporarily get the app working:
- ssh-ing into the VPS and manually restarting the container
- clearing the following cookies form the browser’s storage
Has someone else encountered this wierd behaviour? If so what’s causing it and how could it be solved?
The fact that it takes a different amount of time every deploy makes me think the configuration might be cached and that just runs out after x amount of hours. In any case I would definitely check any chache related commands, like
php artisan optimizefor example.Also, have you configured the CORS middlewares? I've run into similar issues while deploying.