HAProxy ACL Not Working

I'm building a load balancer using HAProxy. I want to have a frontend with multiple backend, divided using path. For example:

  • 172.20.20.10/tomcat1 using backend tomcat1
  • 172.20.20.10/tomcat2 using backend tomcat2

(172.20.20.10) is the HAProxy Node IP.

Here is my config:

frontend frontend
    bind *:80

    option httpclose

    acl tomcat1acl url_beg /tomcat1
    acl tomcat2acl url_beg /tomcat2

    use_backend tomcat1backend if tomcat1acl
    use_backend tomcat2backend if tomcat2acl

backend tomcat1backend
    balance roundrobin
    mode http
    server serv01 172.20.20.20:8080 check

backend tomcat2backend
    balance roundrobin
    mode http
    server serv01 172.20.20.25:8084 check

But I'm getting error 503 Service Unavailable on both 172.20.20.10/tomcat1 and 172.20.20.10/tomcat2. Is there any misconfig ?


Solution 1:

Try adding ‘mode http’ to the frontend definition, like the backends. If it’s not defaulted to http elsewhere. I believe that’s what Ahmed Gamal was getting at in 2018.