default_action applies (defaults to challenge). Rules can match on the URL path, the User-Agent header, or a client IP address or CIDR range. The three actions are allow (pass the request through to the upstream), challenge (serve a CAPTCHA), and deny (block the request immediately).
Inline rules (config.json)
You can define rules directly inconfig.json under the rules array. Each rule has a match object and an action string.
string
A regular expression matched against the request URL path. The rule fires when the path matches.
string
A regular expression matched against the
User-Agent header. The rule fires when the header matches.array of strings
A list of IP addresses or CIDR ranges. The rule fires when the client IP falls within any of the listed ranges.
string
required
What to do when the rule matches. One of
allow, challenge, or deny.Rules are first-match-wins and are evaluated from top to bottom. Put more specific rules before broader ones to avoid an early rule shadowing a later one.
Plain-text rules file
For larger rule sets, or when you want to update rules without restarting verifyngo, setrules_file in config.json to a path and create a .txt file there. verifyngo watches the file and picks up any edits within about 10 seconds.
<action> <type> <pattern>. Here is the full example from rules.txt.example:
path— matches the request URL path using the pattern as a regular expression.ua— matches theUser-Agentheader using the pattern as a regular expression.cidr— matches the client IP against a single CIDR range (or a bare IP address).
# are treated as comments and skipped. Empty lines are also ignored.
YAML policy file
For more advanced matching, setpolicy_file in config.json to a YAML file path. The policy file lets you define named network groups and write expressive conditions that can match on path, user agent, HTTP method, IP address, request headers, and more.
networks— named groups of IP ranges or ASNs that you can reference in rule conditions.conditions— named, reusable expressions you can reference inside rules.rules— the list of rules to evaluate, each with aname,action, and one or more conditions.
path— the request URL path.userAgent— theUser-Agentheader value.method— the HTTP method (e.g.GET,POST).ip— the client IP address as a string.headers["Header-Name"]— any request header value.
matches(value, "regex")— true if the value matches the regular expression.contains(value, "substring")— true if the value contains the substring.startsWith(value, "prefix")— true if the value starts with the prefix.network(ip, "group_name")— true if the IP falls within the named network group.
When
policy_file is set, verifyngo uses the policy file exclusively and ignores both rules and rules_file. Like the plain-text rules file, the policy file is reloaded automatically within about 10 seconds whenever it changes on disk.