HAProxy Enterprise Documentation 1.7r1

add acl

Add a value to an ACL expression or file.

Description

An ACL is split into four parts:

  • a name for the ACL, which you choose

  • a fetch to collect information from the client's session

  • optional flags

  • a value to match against

In the example below, we mark these parts:

frontend www
   bind :80
   #   name       fetch  flags       value
   acl static_url  path   -i -m beg   /images/

Here, there is initially one value, /images/. Use add acl to add another value.

You can also store values in a file and then reference that file in an acl statement by using the -f /path/to/file flag. Use the add acl command to add a new entry to the file. Note that this only adds it to HAProxy Enterprise's runtime memory and not to the file on disk.

Examples

In this example, we start with the following ACL expression in the configuration, which checks whether the requested URL path begins with /images/:

frontend www
   bind :80
   acl static_url path -i -m beg /images/

First, display a list of defined ACLs by calling show acl:

$ echo "show acl" | socat stdio tcp4-connect:127.0.0.1:9999

# id (file) description
0 () acl 'path' file '/etc/hapee-1.7/hapee-lb.cfg' line 51

Use add acl to add the value /scripts/. Pass to it the ID of the ACL:

$ echo "add acl #0 /scripts/" | socat stdio tcp4-connect:127.0.0.1:9999

This updates the ACL so that it represents this expression:

frontend www
   bind :80
   acl static_url path -i -m beg /images/ /scripts/

ACL values may also be stored in a file. Given you have a file named paths.acl with the following list of values:

/images/
/scripts/

You would reference this file with an ACL expression like this:

frontend www
   bind :80
   acl static_url path -i -m beg -f /etc/hapee-1.7/paths.acl

In the next example, we add the value /stylesheets/ to the ACL file /etc/hapee-1.7/paths.acl.

$ echo "add acl /etc/hapee-1.7/paths.acl /stylesheets/" | socat stdio tcp4-connect:127.0.0.1:9999

See also


Next up

add map