Load Balancing: My question is related to this but provides very little info: How to redirect to different servers based on login username? I have three (3) cloud servers at the same data center. The three delivers similar content but only one holds database that serves others. Is there a way to direct or redirect Incoming request to specific server based on users IP Address or username either on Apache or nginx? Cloud service providers offers load balancing services that may serve but the financial cost is making me consider other alternatives. Docs at https://www.nginx.com/resources/glossary/load-balancing/ states the objective "IP Hash – The IP address of the client is used to determine which server receives the request." - this is the objective but then I will like to confirm on the database that they are on the right server. If any PHP script can also do this, please help with it
Asked
Active
Viewed 240 times
1 Answers
0
The Server Fault on mod_proxy you linked accomplishes this. The cookie name set by stickysession
in the configuration is the node ID to look up in the route
list. The first request could go to any server. That backend then logs them in and sets the session.
You mentioned by source IP, which I could not find a module for mod_proxy. Other load balancers have this algorithm.
If your 3 app servers are the same, it should not matter much which users are logged in where. Should you care to enforce this, you will need to add to your app a check that the session information matches this node. Decide what to do in this error condition.

John Mahowald
- 32,050
- 2
- 19
- 34