Skip to content

Commit 105af5d

Browse files
authored
docs: Add more condition/operators (#12339)
Went through the hrw4u symbols.py conditionals and operators, and tried to add the missing ones to the hrw4u doc. Also added section names in the header_rewrite doc so that the "parts" could be quickly referenced.
1 parent 1e1d1cb commit 105af5d

2 files changed

Lines changed: 33 additions & 18 deletions

File tree

doc/admin-guide/configuration/hrw4u.en.rst

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -149,26 +149,31 @@ cond %{ACCESS:/path} access("/path") File exists a
149149
cond %{CACHE} =hit-fresh cache() == "hit-fresh" Cache lookup result status
150150
cond %{CIDR:24,48} =ip cidr(24,48) == "ip" Match masked client IP address
151151
cond %{CLIENT-HEADER:X} =foo inbound.req.X == "foo" Original client request header
152-
cond %{CLIENT-URL:<C> =bar inbound.url.<C> == "bar" URL component match, ``C`` is ``host``, ``path`` etc.
152+
cond %{CLIENT-URL:<C> =bar inbound.url.<C> == "bar" URL component match, <:ref:`C<admin-plugins-header-rewrite-url-parts>`> is ``host``, ``path`` etc.
153+
153154
cond %{COOKIE:foo} =bar {in,out}bound.cookie.foo == "bar" Check a cookie value
154-
cond %{FROM-URL:<C>} =bar from.url.<C> == "bar" Remap ``From URL`` component match, ``C`` is ``host`` etc.
155-
cond %{HEADER:X} =foo {in,out}bound.req.X == "foo" Context sensitive header conditions
156-
cond %{ID:UNIQUE} =... id.UNIQUE == "..." Unique transaction identifier
155+
cond %{FROM-URL:<C>} =bar from.url.<C> == "bar" Remap ``From URL`` component match, <:ref:`C<admin-plugins-header-rewrite-url-parts>`> is ``host`` etc.
156+
cond %{HEADER:X} =fo {in,out}bound.{req,resp}.X == "fo" Context sensitive header conditions
157+
cond %{ID:UNIQUE} =... id.UNIQUE == "..." (:ref:`Unique/request/process<admin-plugins-header-rewrite-id>`) transaction identifier
157158
cond %{INTERNAL-TRANSACTION} internal() Check if transaction is internally generated
158159
cond %{IP:CLIENT} ="..." inbound.ip == "..." Client's IP address. Same as ``inbound.REMOTE_ADDR``
159160
cond %{IP:INBOUND} ="..." inbound.server == "..." ATS's IP address to which the client connected
160161
cond %{IP:SERVER} ="..." outbound.ip == "..." Upstream (next-hop) server IP address
161162
cond %{IP:OUTBOUND} ="..." outbound.server == "..." ATS's outbound IP address, connecting upstream
162163
cond %{LAST-CAPTURE:<#>} ="..." capture.<#> == "..." Last capture group from regex match (range: `0-9`)
163164
cond %{METHOD} =GET inbound.method == "GET" HTTP method match
164-
cond %{NEXT-HOP:<C>} ="bar" outbound.url.<C> == "bar" Next-hop URL component match, ``C`` is ``host`` etc.
165-
cond %{NOW:<U>} ="..." now.<U> == "..." Current date/time in format, ``U`` selects time unit
165+
cond %{NEXT-HOP:<C>} ="bar" outbound.url.<C> == "bar" Next-hop URL component match, <:ref:`C<admin-plugins-header-rewrite-url-parts>`> is ``host`` etc.
166+
cond %{NOW:<U>} ="..." now.<U> == "..." Current date/time in format, <:ref:`U<admin-plugins-header-rewrite-geo>`> selects time unit
166167
cond %{RANDOM:500} >250 random(500) > 250 Random number between 0 and the specified range
167168
cond %{SSN-TXN-COUNT} >10 ssn-txn-count() > 10 Number of transactions on server connection
168-
cond %{TO-URL:<C>} =bar to.url.<C> == "bar" Remap ``To URL`` component match, ``C`` is ``host`` etc.
169+
cond %{TO-URL:<C>} =bar to.url.<C> == "bar" Remap ``To URL`` component match, <:ref:`C<admin-plugins-header-rewrite-url-parts>`> is ``host`` etc.
169170
cond %{TXN-COUNT} >10 txn-count() > 10 Number of transactions on client connection
170171
cond %{URL:<C> =bar {in,out}bound.url.<C> == "bar" Context aware URL component match
171-
cond ${GEO:<C>} =bar geo.<C> == "bar" IP to Geo mapping. ``C`` is ``country``, ``asn`` etc.
172+
cond %{GEO:<C>} =bar geo.<C> == "bar" IP to Geo mapping. <:ref:`C<admin-plugins-header-rewrite-geo>`> is country, asn, etc.
173+
cond %{STATUS} =200 inbound.status ==200 Origin http status code
174+
%{TCP-INFO} tcp.info TCP Info struct field values
175+
cond %{HTTP-CNTL:<C>} http.cntl.<C> Check the state of the <:ref:`C<admin-plugins-header-rewrite-set-http-cntl>`> HTTP control
176+
cond %{INBOUND:<C>} {in,out}bound.conn.<c> inbound (:ref:`client, user agent<admin-plugins-header-rewrite-inbound>`) connection to ATS
172177
=============================== ================================== ================================================
173178

174179
The conditions operating on headers and URLs are also available as operators. E.g.:
@@ -204,16 +209,17 @@ rm-destination QUERY ... remove_query("foo,bar") Remove specified
204209
rm-destination QUERY ... [I] keep_query("foo,bar") Keep only specified query keys
205210
run-plugin foo.so "args" run-plugin("foo.so", "arg1", ...) Run an external remap plugin
206211
set-body "foo" inbound.resp.body = "foo" Set the response body
207-
set-body-from "https://..." set-body-from("https://...") Set the response body from a URL
212+
set-body-from "\https://..." set-body-from("\https://...") Set the response body from a URL
208213
set-config <name> 12 set-config("name", 17) Set a configuration variable to a value
209214
set-conn-dscp 8 inbound.conn.dscp = 8 Set the DSCP value for the connection
210215
set-conn-mark 17 inbound.conn.mark = 17 Set the MARK value for the connection
211216
set-cookie foo bar {in,out}bound.cookie.foo = "bar" Set a request/response cookie named foo
212-
set-destination <C> bar inbound.url.<C> = "bar" Set a URL component, ``C`` is path, query etc.
213-
set-header X-Bar foo inbound.req.X-Bar = "foo" Assign a client request header
214-
set-redirect <Code> <URL> set-redirect(302, "https://...") Set a redirect response
217+
set-destination <C> bar inbound.url.<C> = "bar" Set a URL component, <:ref:`C<admin-plugins-header-rewrite-url-parts>`> is path, query etc.
218+
set-header X-Bar foo inbound.{req,resp}.X-Bar = "foo" Assign a client request/origin response header
219+
set-redirect <Code> <URL> set-redirect(302, "\https://...") Set a redirect response
215220
set-status 404 http.status = 404 Set the response status code
216221
set-status-reason "No" http.status.reason = "no" Set the response status reason
222+
set-http-cntl http.cntl.<C> = bool Turn on/off <:ref:`C<admin-plugins-header-rewrite-set-http-cntl>`> controllers
217223
============================= ================================= ================================================
218224

219225
In addition to those operators above, HRW4U supports the following special operators without arguments:
@@ -230,9 +236,9 @@ String concatenations
230236
---------------------
231237

232238
You can concatenate values using strings, condition values and variable expansions on the same line in
233-
operators using. For instance, `outbound.req.CustomHeader “Hello from {inbound.ip}:{inbound.port}”`. As
234-
a result, the set-redirect's `[QSA]` flag would be implemented as `set-redirect(302, "https://...?{inbound.url.query}")``.
235-
Note the presence of the `?` -- the url.query doesn't include it.
239+
operators using. For instance, ``outbound.req.CustomHeader = “Hello from {inbound.ip}:{inbound.port}”``. As
240+
a result, the set-redirect's ``[QSA]`` flag would be implemented as ``set-redirect(302, "https://...?{inbound.url.query}")``.
241+
Note the presence of the ``?`` -- the url.query doesn't include it.
236242

237243

238244
Semantics
@@ -567,9 +573,6 @@ the ``CACHE`` condition results to a header.::
567573
if inbound.resp.All-Cache != "" {
568574
inbound.resp.All-Cache = "{inbound.resp.All-Cache}, {cache()}";
569575
}
570-
}
571-
572-
SEND_RESPONSE {
573576
if inbound.resp.All-Cache == "" {
574577
inbound.resp.All-Cache = "{cache()}";
575578
}

doc/admin-guide/plugins/header_rewrite.en.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ Per-Mapping`_ above.
318318
The ``<part>`` allows the operand to match against just a component of the URL,
319319
as documented in `URL Parts`_ below.
320320

321+
.. _admin-plugins-header-rewrite-geo:
322+
321323
GEO
322324
~~~
323325
::
@@ -429,6 +431,8 @@ are of the same name as for `set-http-cntl`_. This condition returns a ``true``
429431

430432
would only continue evaluation if logging is turned off.
431433

434+
.. _admin-plugins-header-rewrite-id:
435+
432436
ID
433437
~~
434438
::
@@ -449,6 +453,8 @@ arguments to another operator. For example::
449453

450454
set-header ATS-Req-UUID %{ID:UNIQUE}
451455

456+
.. _admin-plugins-header-rewrite-inbound:
457+
452458
INBOUND
453459
~~~~~~~
454460
::
@@ -596,6 +602,8 @@ For example::
596602
cond %{NEXT-HOP:HOST} =www.secondparent.com
597603
set-header Host vhost.secondparent.com
598604

605+
.. _admin-plugins-header-rewrite-now:
606+
599607
NOW
600608
~~~
601609
::
@@ -1116,6 +1124,8 @@ set-cookie
11161124
Replaces the value of cookie ``<name>`` with ``<value>``, creating the cookie
11171125
if necessary.
11181126

1127+
.. _admin-plugins-header-rewrite-set-http-cntl:
1128+
11191129
set-http-cntl
11201130
~~~~~~~~~~~~~
11211131
::
@@ -1202,6 +1212,8 @@ Old expansion variable Condition variable to use with concatenations
12021212
%<cquup> %{CLIENT-URL:PATH}
12031213
======================== ==========================================================================
12041214

1215+
.. _admin-plugins-header-rewrite-url-parts:
1216+
12051217
URL Parts
12061218
---------
12071219

0 commit comments

Comments
 (0)