
Solved Too many Redirects Issue from AWS EC2 using Load balancers.
Table of Contents
What is Load Balancers?
As you know Load balancers are pretty much required for every heavy traffic/load application.
Load balancers basically works as a reverse proxy and distributes network or application traffic across a number of servers.
Problem statement
When configuring number of servers with you load balancers, we always make sure that the load balancers should target to the mentioned servers in the Target group of AWS.
However, working on to setup all of the networking part I got into one issue it took lot of time.
In fact, it drives me crazy at the point where had I to redo setup twice it took almost my day to figure out what is wrong.
So thought wring an article could help people fixing their issue and save time.
You might think what was the error?
Let me tell it was session/state related error, so we tried to login the logins worked however as we had multiple servers on Load balancers, obviously a user should only connect to One of them at a time.
Infact user were connecting to the Single Server at time, but the problem was for each request user were dynamically getting connected to random server from the target group
And that’s the reason I was getting TOO_MANY_REDIRECTS Error (310) issue.
Eventually what was happening is that the session was getting created only one of the servers and load balancer were not sticking to the server.
And just because of the sticky setting were missed while configuring the Target groups to the Load balancers and EC2 instances.
Solution:
To solve this issue, what you need to do is just make sure that the Stickiness is enabled on your Target group.
The thing is you can only edit or enable this setting after creating the security Group not while creating.
So, as soon as you create a Target group for your Load balancer make sure to add/edit the Stickiness and enable it just like showing below:
