Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Routing HTTP Based on Source IP in HAProxy

I've been reading through HAProxy's documentation, and I could not seem to find a way to route HTTP requests based on the source IP address. That is, I want to route specific sources to specific backend servers. For example, I want to route any request that's coming from 10.1.0.3 to one specific server.

like image 916
ObjProg Avatar asked Feb 20 '26 18:02

ObjProg


1 Answers

You can use ACL for this king of settings.

Example:

  acl sub1 src 192.168.0.0/24
  acl sub2 src 192.168.1.0/24

  use backend back1 if sub1
  use backend back2 if sub2

Then you have to declare both backend server back1 and back2

I hope this help. Regards,

like image 134
JCB Avatar answered Feb 24 '26 13:02

JCB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!