Specifications
Chapter 8: Working with Match Rules
126 Equalizer Installation and Administration Guide
With the addition of the logical OR (||) and logical AND (&&) operators, you can specify complex
expressions, selecting precise attributes from the request, as in this:
NOT happy() || (round() && happy())
Match expressions are read from left to right. Expressions contained within parentheses get
evaluated before other parts of the expression. The previous expression would match anything that
was not red or that was round and happy.
Unlike the previous example, match functions correspond to certain attributes in a request header.
For example, a request URI for a web page might look like this:
Get /somedir/somepage.html http/1.1
Accept: text/html, text/*, *.*
Accept-Encoding: gzip
Host: www.coyotepoint.com
User-Agent: Mozilla/4.7 [en] (Win98; U)
Various functions return true when their arguments match certain components of the request URI.
Using the above request URI, for example, you could use several match functions:
• pathname() returns true if its argument matches /somedir/somepage.html
• dirname() returns true if its argument matches /somedir/
• filename() returns true if its argument matches somepage.html
Other functions can evaluate the contents of the Host header in the request URI above:
host (www.coyotepoint.com)
host_prefix (www)
host_suffix (coyotepoint.com).
Some function arguments can take the form of a regular expression
1
. Note that you cannot put
regular expressions into match expressions except as an argument to a function whose definition
supports regular expressions.
Note – The the logical negation operator is displayed as “NOT”, rather than “!”.
1. Regular expressions are specified according to IEEE Std 1003.2 (“POSIX.2”).
Note – Matching regular expressions (using *_regex() functions) is many times more
processing-intensive than using other match functions. It is usually possible to avoid using
regular expressions by carefully crafting match expressions using other functions. For example,
the following regular expression match:
dirname_regex("(two|four|six|eight)")
Can be replaced by the more efficient:
dirname_substr("two") ||
dirname_substr("four") ||
dirname_substr("six") ||
dirname_substr("eight")