I need to redirect based on a URL parameter. For example,
curl -X POST 'http://load-balancer:27300/path?appid=1' should always hit app-1
curl -X POST 'http://load-balancer:27300/path?appid=2' should always hit app-2
I tried the below configurations on HAProxy 1.5.18-6.el7, but it redirects to different servers each time. It behaves as if its balance roundrobin.
frontend front
bind *:27300
default_backend back
backend back
acl app1_url urlp(appid) 1
acl app2_url urlp(appid) 2
use-server app1 if app1_url
use-server app2 if app2_url
server app1 192.168.250.11:7300 check
server app2 192.168.250.31:7300 check