I have configured a load balancer using HAProxy on frontend and on the backend I have 4 server serving the request using Apache web server.
#HAProxy for web servers
frontend web-frontend
bind IPADDRESS_LB:80
mode http
default_backend web-backend
backend web-backend
balance roundrobin
server web-server1 IPADDRESS1:80 check
server web-server2 IPADDRESS2:80 check
server web-server3 IPADDRESS3:80 check
server web-server4 IPADDRESS4:80 check
My requests are served by either of the machines in a round robin mechanism. But now I want to implement my own algorithm to send the request based on the request parameters, eg IP.
Like Implementing my own hash function based on the result of which I can route my request to either of the backend servers.
How can I do that?