From d54e8f8107165de549bfbd78c5c0b8e549c9f880 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 30 Nov 2023 09:28:39 +0100 Subject: [PATCH] DOC: config: reorganize actions into their own section The split of the rulesets from their respective actions has long been overdue so it's time to do it because it has become extremely difficult to add simple actions in the documentation, as well as it's hard to find them. This commit creates two new sections "4.3 Actions keywords matrix" and "4.4 Alphabetically sorted actions reference" that enumerates all known actions, with a check indicating for which rule sets they're valid. This removes all the repetition, occurrences of "see http-request blah for details" and significantly reduces the number of keywords listed in the proxies section. This removes 2245 lines from the proxies section in exchange of 1608 in these new sections. --- doc/configuration.txt | 3853 +++++++++++++++++------------------------ 1 file changed, 1608 insertions(+), 2245 deletions(-) diff --git a/doc/configuration.txt b/doc/configuration.txt index 59c685e56e..2c7ada20f6 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -60,6 +60,8 @@ Summary 4. Proxies 4.1. Proxy keywords matrix 4.2. Alphabetically sorted keywords reference +4.3. Actions keywords matrix +4.4. Alphabetically sorted actions reference 5. Bind and server options 5.1. Bind options @@ -6246,44 +6248,29 @@ http-after-response [ { if | unless } ] The http-after-response statement defines a set of rules which apply to layer 7 processing. The rules are evaluated in their declaration order when they - are met in a frontend, listen or backend section. Any rule may optionally be - followed by an ACL-based condition, in which case it will only be evaluated - if the condition is true. Since these rules apply on responses, the backend - rules are applied first, followed by the frontend's rules. + are met in a frontend, listen or backend section. Since these rules apply on + responses, the backend rules are applied first, followed by the frontend's + rules. Any rule may optionally be followed by an ACL-based condition, in + which case it will only be evaluated if the condition evaluates true. Unlike http-response rules, these ones are applied on all responses, the server ones but also to all responses generated by HAProxy. These rules are - evaluated at the end of the responses analysis, before the data forwarding. + evaluated at the end of the responses analysis, before the data forwarding + phase. - The first keyword is the rule's action. Several types of actions are - supported: - - add-header - - allow - - capture id - - del-acl() - - del-header [ -m ] - - del-map() - - replace-header - - replace-value - - sc-add-gpc(,) { | } - - sc-inc-gpc(,) - - sc-inc-gpc0() - - sc-inc-gpc1() - - sc-set-gpt(,) { | } - - sc-set-gpt0() { | } - - set-header - - set-log-level - - set-map() - - set-status [reason ] - - set-var([,...]) - - set-var-fmt([,...]) - - strict-mode { on | off } - - unset-var() + The condition is evaluated just before the action is executed, and the action + is performed exactly once. As such, there is no problem if an action changes + an element which is checked as part of the condition. This also means that + multiple actions may rely on the same condition so that the first action that + changes the condition's evaluation is sufficient to implicitly disable the + remaining actions. This is used for example when trying to assign a value to + a variable from various sources when it's empty. There is no limit to the + number of "http-after-response" statements per instance. - The supported actions are described below. - - There is no limit to the number of http-after-response statements per - instance. + The first keyword after "http-after-response" in the syntax is the rule's + action, optionally followed by a varying number of arguments for the action. + The supported actions and their respective syntaxes are enumerated in section + 4.3 "Actions" (look for actions which tick "HTTP Aft"). This directive is only available from named defaults sections, not anonymous ones. Rules defined in the defaults section are evaluated before ones in the @@ -6301,134 +6288,6 @@ http-after-response [ { if | unless } ] http-after-response set-header Cache-Control "no-store,no-cache,private" http-after-response set-header Pragma "no-cache" -http-after-response add-header [ { if | unless } ] - - This appends an HTTP header field whose name is specified in and whose - value is defined by . Please refer to "http-request add-header" for a - complete description. - -http-after-response allow [ { if | unless } ] - - This stops the evaluation of the rules and lets the response pass the check. - No further "http-after-response" rules are evaluated for the current section. - -http-after-response capture id [ { if | unless } ] - - This captures sample expression from the response buffer, and - converts it to a string. Please refer to "http-response capture" for a - complete description. - -http-after-response del-acl() [ { if | unless } ] - - This is used to delete an entry from an ACL. Please refer to "http-request - del-acl" for a complete description. - -http-after-response del-header [ -m ] [ { if | unless } ] - - This removes all HTTP header fields whose name is specified in . Please - refer to "http-request del-header" for a complete description. - -http-after-response del-map() [ { if | unless } ] - - This is used to delete an entry from a MAP. Please refer to "http-request - del-map" for a complete description. - -http-after-response replace-header - [ { if | unless } ] - - This works like "http-response replace-header". - - Example: - http-after-response replace-header Set-Cookie (C=[^;]*);(.*) \1;ip=%bi;\2 - - # applied to: - Set-Cookie: C=1; expires=Tue, 14-Jun-2016 01:40:45 GMT - - # outputs: - Set-Cookie: C=1;ip=192.168.1.20; expires=Tue, 14-Jun-2016 01:40:45 GMT - - # assuming the backend IP is 192.168.1.20. - -http-after-response replace-value - [ { if | unless } ] - - This works like "http-response replace-value". - - Example: - http-after-response replace-value Cache-control ^public$ private - - # applied to: - Cache-Control: max-age=3600, public - - # outputs: - Cache-Control: max-age=3600, private - -http-after-response sc-add-gpc(,) { | } - [ { if | unless } ] - - This action increments the General Purpose Counter according to the sticky - counter designated by . Please refer to "http-request sc-add-gpc" for - a complete description. - -http-after-response sc-inc-gpc(,) [ { if | unless } ] -http-after-response sc-inc-gpc0() [ { if | unless } ] -http-after-response sc-inc-gpc1() [ { if | unless } ] - - These actions increment the General Purppose Counters according to the sticky - counter designated by . Please refer to "http-request sc-inc-gpc", - "http-request sc-inc-gpc0" and "http-request sc-inc-gpc1" for a complete - description. - -http-after-response sc-set-gpt(,) { | } - [ { if | unless } ] -http-after-response sc-set-gpt0() { | } - [ { if | unless } ] - - These actions set the 32-bit unsigned General Purpose Tags according to the - sticky counter designated by . Please refer to "http-request - sc-set-gpt" and "http-request sc-set-gpt0" for a complete description. - -http-after-response set-log-level [ { if | unless } ] - - This is used to change the log level of the current response. Please refer to - "http-request set-log-level" for a complete description. - -http-after-response set-map() - - This is used to add a new entry into a MAP. Please refer to "http-request - set-map" for a complete description. - -http-after-response set-header [ { if | unless } ] - - This does the same as "http-after-response add-header" except that the header - name is first removed if it existed. This is useful when passing security - information to the server, where the header must not be manipulated by - external users. - -http-after-response set-status [reason ] - [ { if | unless } ] - - This replaces the response status code with which must be an integer - between 100 and 999. Please refer to "http-response set-status" for a complete - description. - -http-after-response set-var([,...]) [ { if | unless } ] -http-after-response set-var-fmt([,...]) [ { if | unless } ] - - This is used to set the contents of a variable. The variable is declared - inline. Please refer to "http-request set-var" and "http-request set-var-fmt" - for a complete description. - -http-after-response strict-mode { on | off } [ { if | unless } ] - - This enables or disables the strict rewriting mode for following - rules. Please refer to "http-request strict-mode" for a complete description. - -http-after-response unset-var() [ { if | unless } ] - - This is used to unset a variable. See "http-request set-var" for details - about . - http-check comment Defines a comment for the following the http-check rule, reported in logs if @@ -6994,75 +6853,21 @@ http-request [options...] [ { if | unless } ] processing. The rules are evaluated in their declaration order when they are met in a frontend, listen or backend section. Any rule may optionally be followed by an ACL-based condition, in which case it will only be evaluated - if the condition is true. + if the condition evaluates to true. - The first keyword is the rule's action. Several types of actions are - supported: - - add-acl() - - add-header - - allow - - auth [realm ] - - cache-use - - capture [ len | id ] - - del-acl() - - del-header [ -m ] - - del-map() - - deny [ { status | deny_status } ] ... - - disable-l7-retry - - do-resolve(,,[ipv4,ipv6]) - - early-hint - - normalize-uri - - redirect - - reject - - replace-header - - replace-path - - replace-pathq - - replace-uri - - replace-value - - return [status ] [content-type ] ... - - sc-add-gpc(,) { | } - - sc-inc-gpc(,) - - sc-inc-gpc0() - - sc-inc-gpc1() - - sc-set-gpt(,) { | } - - sc-set-gpt0() { | } - - set-bandwidth-limit [limit { | }] [period { |