I have a Laravel application running on Elastic Beanstalk. The app works fine with one EC2 instance running, but whenever EB scales and adds a second instance, the app redirects all requests back to the login page, and eventually fails with a ERR_TOO_MANY_REDIRECTS error. EB eventually scales back down to one instance, and everything works fine again.
I've followed the AWS steps here to redirect HTTP to HTTPS using listeners. The problem seems similar to this one, but I have an Application Load Balancer rather than a Classic LB, I've set up the redirect the "right" way, and I've make sure there are no other redirects set at the nginx or .htaccess level.
I am using Laravel's URL::forceScheme('https') to rewrite links as https, but I don't believe this has any affect on redirects.
Can anyone advise on next steps for debugging? For now, the only preventative workaround I've found is to limit EB to a single instance.
I had the same scenario happen for a laravel application on EB with an ALB, but could not figure out why the redirects were occurring (thought it was due to rewrite rules on the .htaccess file causing requests to jump from instance to instance endlessly). In my case, users were being redirected to the login page persistently.
Configuring sticky sessions on my target group fixed the issue. I used the load balancer generated cookie as the type and a duration of 1hr.