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:
For each one of these technologies there is a Docker container. The communication between them is facilitated by a traefik Docker network. (all containers are on the same droplet)
These are some of the environment configuration variables I use that I think might be relevant for the problem:
CACHE_DRIVER: "redis"
QUEUE_CONNECTION: "redis"
SESSION_DRIVER: "redis"
💡 also for the second web platform I did’t configure the Redis and Melisearch services and I only run 2 Docker containers, for the app and database.
CACHE_DRIVER: "file"
QUEUE_CONNECTION: "sync"
SESSION_DRIVER: "file"
The following things can be done to temporarily get the app working:
💡 Note that the develop environment, the one on which the web applications work with no problems is on a self-hosted and maintained server that also has a DNS, CDN and revers-proxy provider on top
Has someone else encountered this wierd behaviour? If so what’s causing it and how could it be solved?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hey!
This is quite interesting. Since this is an intermittent issue and the fact that it works initially, I suspect it might be related to server resource utilization like RAM and CPU utilization.
To verify if this is indeed the case, monitor your server’s memory usage. If the server is running out of memory, it might kill processes, including those handling sessions:
Also, I could suggest a couple of things here:
On another note, can you also verify the session lifetime configuration is in your
config/session.php
file? The default session lifetime might be too short causing that issue.- Bobby