Skip to main content
Anubis uses YAML-based policy files to define bot protection rules, storage backends, logging, and other security settings. This page covers the structure and loading of policy files.

Policy File Structure

A complete policy file includes:

Loading Policy Files

Anubis loads policy files using the --policy-fname flag or POLICY_FNAME environment variable:
If no policy file is specified, Anubis uses a built-in default policy from data/botPolicies.yaml.

Import Statements

Policy files support importing other YAML files:
The (data)/ prefix references embedded policy files shipped with Anubis.

Configuration Validation

Anubis validates all configuration at startup using the Valid() method pattern. Common validation errors:

Required Fields

  • At least one bot rule must be defined (ErrNoBotRulesDefined)
  • Each bot rule must have a name field (ErrBotMustHaveName)
  • Bots must match on at least one field: user_agent_regex, path_regex, headers_regex, remote_addresses, or expression (ErrBotMustHaveUserAgentOrPath)

Rule Actions

Valid actions are:
  • ALLOW - Bypass all checks and forward to backend
  • DENY - Block the request with a fake success page
  • CHALLENGE - Present a proof-of-work challenge
  • WEIGH - Adjust request suspicion weight
  • DEBUG_BENCHMARK - Development only

Regular Expression Validation

Regular expressions are compiled at config load time. Common issues:
  • Regex ending with newline (ErrRegexEndsWithNewline) - use >- instead of > in YAML:

CIDR Validation

IP address ranges in remote_addresses must be valid CIDR notation:

Configuration Defaults

If not specified in the policy file, Anubis uses these defaults:

Environment-Specific Configuration

Policy files can reference environment variables through standard Go flag environment variable support:

Configuration Reloading

Anubis does not currently support hot-reloading of policy files. Configuration changes require a service restart:

Next Steps