pcre: ,log in an action writes what the pattern matched (#794)

An action word of a pcre or pcre_rewrite rule may end with ,log: every
match writes a record of its own carrying the matched part of the
buffer, so a header can be watched without changing the request's fate
(dunno,log), or a refusal can leave its trace (deny,log). The matched
text reaches the log through %T, like any service text. The pcre
options apply to such a pattern as to any other, so it can be written
case-insensitively and by the line.
This commit is contained in:
Vladimir Dubrovin committed 2026-11-21 14:21:16 +03:00
1 parent 251a91d6b4
commit c36e3f5b8e
3 files changed
+110 -1

No files matched your search

+14
View File
@@ -1801,6 +1801,20 @@ FILTER_ACTION - action on match:
deny - deny this request without checking the rest of the rules
.br
dunno - continue with the rest of the rules (useful with pcre_rewrite)
.br
An action may be followed by ,log (as in allow,log or dunno,log): what
the pattern matched is written to the log as a record of its own, one
per match, in addition to the connection's own record. Put %T in
logformat to have the matched text in the line. The options apply to the
pattern as to any other, so for example
.br
pcre_options PCRE2_CASELESS PCRE2_MULTILINE
.br
pcre cliheader dunno,log "^user-agent:.*$"
.br
watches the User-Agent: header whatever its case, with the ^ and $
anchors holding for every line of the headers, wherever the header
comes, and decides nothing about the request.
REGEXP - PCRE (Perl) regular expression. Use * if no regexp matching is required.