HAProxy load balancing based on source ip (IP subnet)
I have x cluster. This cluster look like
Cluster 1
192.168.1. (Server type 1)
192.168.2. (Server type 2)
192.168.3.1 (Server type 3) <Redis server>
Cluster 2
192.167.1. (Server type 1)
192.167.2. (Server type 2)
192.167.3.1 (Server type 3) <Redis server>
Currently I am managing cluster group configuration in code. Is it possible to have a domain called as using haproxy And which redirect require based on source ip? For example
192.167.* request gets redirect to 192.167.3.1
and
192.168.* request gets redirect to 192.168.3.1
This is possible with HAProxy ACLs. You need to setup 2 backends, one for each block, then in the frontend create 2 acls, one for each backend.
Your frontend block would look something like this
acl block_7 src 192.167.0.0/16
acl block_8 src 192.168.0.0/16
use_backend block_7_hosts if block_7
use_backend block_8_hosts if block_8
Then define a backends block_7_hosts
and block_8_hosts
with the correct redis server in them.
If you don't plan on adding more Redis servers though you may just want to use a configuration management tool since you aren't really load balancing.