21

I'm trying to match various conditions inside one backend, like this:

acl rule1 hdr_dom(host) -i ext1
acl rule2 utl_beg /img
default_backend back-server-http if rule1 and rule2

but, how can I put this "and" between the two rules?

1

3 Answers 3

25

Yes, this is the solution:

acl rule1  hdr_dom(host) -i www.uno.es  hdr_dom(host) -i www.one.com
use_backend uno.com if rule1
4
  • 1
    How can a request have both hosts? It seems impossible that this ACL could ever be matched.
    – UpTheCreek
    Mar 5, 2015 at 10:32
  • Yes, you can, its the same if you add contidions to the same acl inside different lines.
    – rfmoz
    Apr 10, 2015 at 9:54
  • 1
    the answer example doesn't match the question example: for the question would it be something like this: acl rule1 hdr_dom(host) -i ext1 utl_beg /img?
    – Thayne
    Jun 1, 2015 at 23:30
  • @Thayne - see the examples here: github.com/langpavel/haproxy-doc/blob/master/version-1-4-19/tex/…. Given what you've written I'd expect that to work.
    – slm
    Jun 10, 2015 at 0:30
21

You don't need to use the word "and" between the two rules. It's implicit.

Source: http://haproxy.1wt.eu/download/1.5/doc/configuration.txt in Section 7.2

0
-1

I think the below syntax will do the trick (check this link HAProxy - basic authentication for backend server)

acl rule1 hdr_dom(host) -i ext1
acl rule2 utl_beg /img
default_backend back-server-http if rule1  rule2
1
  • 'default_backend' cannot handle unexpected argument 'if'.
    – Constantin
    Oct 30, 2021 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.