HAProxy community

Anonymous ACL - Multiple AND Conditions Not Evaluted

Trying to understand why this doesn’t work. Only the first condition path_beg is evaluated and the second condition checking the hostname isn’t.

I would expect the following but it seems that only the first condition is checked and the second is ignored. I’ve tried with “&&” “AND” and “” but it doesn’t make any difference.

https://example.com/crowd goes to crowd-backend
https://example.com/jira goes to jira-backend
https://auth.example.com/crowd goes to rancher-backend but it actually goes to jira-backend

  # Atlassian Backends
  use_backend crowd-backend if { path_beg /crowd && hdr(host) example.com }
  use_backend jira-backend if { path_beg /jira && hdr(host) example.com }

  # Rancher Backends
  use_backend rancher-backend if { hdr(host) example.com }
  use_backend keycloak-backend if { hdr(host) auth.example.com }
  use_backend rancher-backend if { hdr(host) chat.example.com }

An anonymous ACL is a condition within braces, like:

{ path_beg /crowd }

Two anonymous ACL’s combined look similar, but the braces need to close and reopen:

{ path_beg /crowd } { hdr(host) example.com }

Because a single conditions can match against multiple patterns, so:

{ path_beg /crowd && hdr(host) example.com }

Means a path that begins with either /crowd or && or hdr(host) or example.com.

And a proper use would look like:

{ path_beg /static /images /img /css }

When I was trying the second syntax I was getting an exception in the config file but I’ll try it again.