Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

haproxy nested conditions for acl

Tags:

haproxy

I need nested ACL conditions

acl route1 hdr_sub(host) -i abc.com hdr_sub(host) -i xyz.com 
acl route2 path_beg /m1
acl route3 path_beg /m2


use backend back1 if route1 (route2 or route3)

// essentially  
route1 AND (route2 OR route3)

to match backends. What would be the correct HA code equivalent to this ?

like image 660
shrw Avatar asked Jul 11 '18 07:07

shrw


People also ask

What is HAProxy ACL?

Access Control Lists, or ACLs, in HAProxy allow you to test various conditions and perform a given action based on those tests.

What is ACL in backend?

Access Control List (ACL) rules allow an admin to limit the permissions of users in Magento. For example, you can use ACL rules to authorize the users to access menus, controllers, API endpoints and conditionally render layout blocks.


1 Answers

Rules in a single ACL are ORed, so, you can combine the route2 and route3 rules with this:

acl route2 path_beg /m1
acl route2 path_beg /m2

use backend back1 if route1 route2

Conditions also support the || operator, but not parenthetical grouping for precedence, so a b || c means (a and b) or (c), which isn't equivalent to what you want... so if you don't want to combine the ACLs as shown above, you would need this...

use backend back1 if route1 route2 || route1 route3

...which is not exactly intuitive.

Or this:

use backend back1 if route1 route2
use backend back1 if route1 route3
like image 187
Michael - sqlbot Avatar answered Oct 19 '22 08:10

Michael - sqlbot