HAProxy Enterprise Documentation 2.0r1


You use a fetch by specifying its name on a line that supports fetches, such as the acl directive. Some fetches have parameters, which are given in parentheses. Omit the parentheses for other fetches that have no parameters.

Here are a few examples of fetches that take no parameters:

# returns the client's source IP address

# returns the requested URL path

# returns the destination TCP port

Here are a few examples of fetches that take parameters:

# returns the number of queued connections in a backend

# returns the value of the Host HTTP header

# returns the value of the "abc" cookie

Every fetch returns a value with one of the following data types:

  • Boolean

  • Integer

  • IP address

  • String

  • Binary

With this in mind, you can write conditional logic that compares the output of a fetch with a hardcoded value that aligns with the fetch's data type. For example, if a fetch returns a string, you can compare it to a hardcoded string or a regular expression, as we do here to check whether the User-Agent header matches the substring firefox:

frontend www
   bind :80

   # Does the User-Agent header contain the string 'Firefox'?
   acl is_firefox req.hdr(user-agent) -i -m sub firefox

Next up

Fetch Reference