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?

slm
  • 15,396
  • 12
  • 109
  • 124
rfmoz
  • 991
  • 4
  • 14
  • 27
  • An other related question: https://serverfault.com/questions/768575/haproxy-acl-multiple-or-conditions – rfmoz Jul 06 '20 at 10:17

3 Answers3

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
Gabriel Hurley
  • 39,690
  • 13
  • 62
  • 88
rfmoz
  • 991
  • 4
  • 14
  • 27
  • 1
    How can a request have both hosts? It seems impossible that this ACL could ever be matched. – UpTheCreek Mar 05 '15 at 10:32
  • Yes, you can, its the same if you add contidions to the same acl inside different lines. – rfmoz Apr 10 '15 at 09: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 01 '15 at 23:30
  • @Thayne - see the examples here: https://github.com/langpavel/haproxy-doc/blob/master/version-1-4-19/tex/gen_07-07--using-acls-to-form-conditions.tex. Given what you've written I'd expect that to work. – slm Jun 10 '15 at 00: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

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115
-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
devops-admin
  • 1,447
  • 1
  • 15
  • 26