Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

An L7 Rule is a single, simple logical test which returns either true or false. It consists of a rule type, a comparison type, a value, and an optional key that gets used depending on the rule type. An L7 rule must always be associated with an L7 policy.

Rules types

L7 rules have the following types:

  • HOST_NAME: does a comparison between the HTTP/1.1 hostname in the request against the value parameter in the rule.
  • PATH: compares the path portion of the HTTP URI against the value parameter in the rule.
  • FILE_TYPE: compares the last portion of the URI against the value parameter in the rule. (eg. “txt”, “jpg”, etc.)
  • HEADER: looks for a header defined in the key parameter and compares it against the value parameter in the rule.
  • COOKIE: looks for a cookie named by the key parameter and compares it against the value parameter in the rule.

Comparaison types

L7 rules of a given type always do comparisons. The types of comparisons supported are listed below. Note that not all rule types support all comparison types:

  • REGEX: Perl type regular expression matching.
  • STARTS_WITH: String starts with.
  • ENDS_WITH: String ends with.
  • CONTAINS: String contains.
  • EQUAL_TO: String is equal to.

...

An L7 Policy is a collection of L7 rules associated with a Listener, and which may also have an association to a back-end pool. Policies describe actions that should be taken by the load balancing software if all of the rules in the policy return true.

Policy logic

Policy logic is very simple: All the rules associated with a given policy are logically ANDed together. A request must match all the policy’s rules to match the policy. If you need to express a logical OR operation between rules, then do this by creating multiple policies with the same action (or, possibly, by making a more elaborate regular expression).

Policy actions

If an L7 policy matches a given request, then that policy’s action is executed. The following are the actions an L7 Policy may take:

  • REJECT: The request is denied with an appropriate response code, and not forwarded on to any back-end pool.
  • REDIRECT_TO_URL: The request is sent an HTTP redirect to the URL defined in the redirect_url parameter.
  • REDIRECT_TO_POOL: The request is forwarded to the back-end pool associated with the L7 policy.

Policy position

When multiple L7 Policies are associated with a listener, then the policies’ position parameter becomes important. The position parameter is used when determining the order in which L7 policies are evaluated. Here are a few notes about how policy position affects listener behavior:

  • In the reference implementation (haproxy amphorae) of Octavia, haproxy enforces the following ordering regarding policy actions:
    • REJECT policies take precedence over all other policies.
    • REDIRECT_TO_URL policies take precedence over REDIRECT_TO_POOL policies.
    • REDIRECT_TO_POOL policies are only evaluated after all of the above, and in the order specified by the position of the policy.
  • L7 Policies are evaluated in a specific order (as defined by the position attribute), and the first policy that matches a given request will be the one whose action is followed.
  • If no policy matches a given request, then the request is routed to the listener’s default pool ,if it exists. If the listener has no default pool, then an error 503 is returned.
  • Policy position numbering starts with 1.
  • If a new policy is created with a position that matches that of an existing policy, then the new policy is inserted at the given position.
  • If a new policy is created without specifying a position, or specifying a position that is greater than the number of policies already in the list, the new policy will just be appended to the list.
  • When policies are inserted, deleted, or appended to the list, the policy position values are re-ordered from 1 without skipping numbers. For example, if policy A, B, and C have position values of 1, 2 and 3 respectively, if you delete policy B from the list, policy C’s position becomes 2.