Skip to content

ezgh waf rules add

Add a rule to a WAF.

Updated View as Markdown
ezgh waf rules add <waf> --name n --action allow|block|log|rate-limit [conditions…] [--position p] [flags]

Add a rule of your own to a WAF, last or at --position (1 is first). Rules run top to bottom, before the managed rule sets, and the first that allows or blocks a request decides it. A rule’s conditions all have to match:

--ip-set c       the client's address is in one of these IPv4 or IPv6 CIDRs; repeat for more
--asn n          the client's network is one of these AS numbers; repeat for more
--country cc     the client's country is one of these (ISO 3166-1 alpha-2); repeat for more
--regex t=v      target t matches the regular expression v (no backreferences or lookaround)
--contains t=v   target t contains v
--equals t=v     target t is v

A target is path, query, method, header:<name>, cookie:<name>, or body, the first 16 KB of a request body. Text matches ignore case. --rule-file gives the whole rule as JSON instead, for negated or case-sensitive conditions.

--action allow lets the request through and skips the managed rule sets; block answers 403; log records it and goes on; rate-limit counts the requests it matches per client address, and blocks a client over --rate-limit per --window seconds (60, 300 or 600) until it’s back under. --mode log on a rate-limit rule records instead of blocking (Log only).

Part of ezgh waf rules.

Examples

ezgh waf rules add waf_k2m9x0a7qpe4 --name office --action allow --ip-set 203.0.113.0/24
ezgh waf rules add waf_k2m9x0a7qpe4 --name admin --action block --regex 'path=^/admin' --position 1
ezgh waf rules add waf_k2m9x0a7qpe4 --name login --action rate-limit --rate-limit 20 --window 60 --equals path=/login --equals method=POST
ezgh waf rules add waf_k2m9x0a7qpe4 --rule-file rule.json

Flags

Flag Type Default Description
--action string allow, block, log or rate-limit
--asn string, repeatable match a client network with this AS number; repeat for more
--contains string, repeatable match a target that contains a value, target=value; repeat for more conditions
--country string, repeatable match a client in this country (ISO 3166-1 alpha-2); repeat for more
--equals string, repeatable match a target that is a value, target=value; repeat for more conditions
--ip-set string, repeatable match a client address in this IPv4 or IPv6 CIDR; repeat for more
--mode string a rate-limit rule’s mode: block, or log to record and not block (default block)
--name string its name, unique in the WAF: 1 to 64 lowercase letters, digits and dashes
--position int where it goes, 1 for first (default last)
--rate-limit int a rate-limit rule’s requests per client per window, 1 to 100000
--regex string, repeatable match target=regex; repeat for more conditions
--rule-file string the rule as JSON (one entry of ezgh waf get -o json’s rules), - for stdin
--window int 60 a rate-limit rule’s window in seconds: 60, 300 or 600

This command also takes the global flags.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close