We’ve created our first Laravel web application. We’ve wired up basic Laravel authentication. Our application also relies on session storage. We’ve been hosting our application on a single web server. So far, everything is working great!
For scalability purposes, we've now moved our web application onto 2 web servers, and setup a load balancer to dynamically route traffic requests between each server. This is where things broke down: it seems session cache and authentication storage are stored locally, per server. For instance, we’ve been using the default SQL Lite file for authentication storage. We’ve been using ‘file’ based configuration for session storage as well. So when users get dynamically bounced back-and-forth between servers, session and authorization become inconsistent and become unreliable.
We’ve attempted to switch both the authentication and session storage to be driven off a shared SQL server instance. But we are concerned that this opens a direct connection between our web server and the SQL server. Meaning, our web application server is publically accessible, but our SQL server sits inside our network. We’d rather not open a firewall hole between these two. Is there a better approach?
Our traditional stack is .NET. In that stack, we tend to have a web application server that hosts custom API endpoints that talk directly to the database, and these APIs just process requests for specific institutional data. While I know Laravel has API capabilities, I cannot imagine it easily allows for “custom API” to facilitate intrinsic authentication and session handling. Also, using memcached or redis doesn’t really help this issue, since I’m not only talking about storing session information, but also Authentication. And default Laravel authentication choices for persistency doesn’t include those items. I am highly hesitant to go too far outside the Laravel provided default choices for persistent storage.
What is the best approach to configure Laravel to manage both session and authentication based on shared persistence storage? Is there a way to limit opening firewall ports/holes between our web application servers, and the backend SQL storage?
We've read and reviewed quite a number of online articles, previous tickets, etc. But none of them directly talk about this specific issue.
Any help or guidance would be appreciated. Thank you.