0

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
Karthik Murugan
  • 1,429
  • 3
  • 17
  • 28
  • This has been answered : https://stackoverflow.com/questions/20606544/haproxy-url-based-routing-with-load-balancing – Gooner Nov 14 '18 at 18:36
  • As responded by @Gonner, this post has the answer https://stackoverflow.com/questions/20606544/haproxy-url-based-routing-with-load-balancing – Karthik Murugan Nov 15 '18 at 08:39
  • 1
    Possible duplicate of [HAProxy - URL Based routing with load balancing](https://stackoverflow.com/questions/20606544/haproxy-url-based-routing-with-load-balancing) – Louis Kriek Nov 27 '18 at 13:29

1 Answers1

0

For posterity, you should have moved the acl in the frontend section, and then:

use_backend app1 if app1_url
use_backend app2 if app2_url

and also add the corresponding backends for these rules.

w00t
  • 616
  • 3
  • 9
  • 16