Skip to main content
Bot rules are the core of Anubis policy configuration. They define how to identify and respond to different types of traffic.

Rule Structure

A bot rule consists of matchers and an action:

Required Fields

Matchers

Rules must include at least one matcher:

Matcher Types

User Agent Matching

Path Matching

Header Matching

IP Range Matching

Combined Matching

Combine IP ranges with other matchers:

CEL Expressions

For advanced matching, use Common Expression Language (CEL) expressions:

Single Expression

Multiple Conditions (all)

All conditions must be true:

Multiple Conditions (any)

At least one condition must be true:

Available Variables

DNS Functions

Available DNS functions:
  • reverseDNS(ip) - Get PTR records
  • lookupHost(hostname) - Get A/AAAA records
  • verifyFCrDNS(ip) - Verify FCrDNS
  • verifyFCrDNS(ip, pattern) - Verify FCrDNS with regex pattern
  • arpaReverseIP(ip) - Convert to ARPA notation

Helper Functions

Rule Actions

ALLOW

Bypass all checks and forward to backend:

DENY

Block with a deceptive success page:

CHALLENGE

Present a proof-of-work challenge:

WEIGH

Adjust request suspicion score:

Rule Evaluation Order

Rules are evaluated in the order they appear in the policy file. The first matching rule determines the action.

Weight-Based Rules

Weight rules accumulate. All matching WEIGH rules apply:

Regular Expression Syntax

Anubis uses Go’s regexp package (RE2 syntax):
Test regex at regex101.com (select Golang flavor).

Common Patterns

Allow Static Assets

Block Known Bad Actors

Protect POST Endpoints

Dynamic Load Protection

Best Practices

  1. Order matters: Place specific ALLOW rules before generic DENY rules
  2. Test expressions: Use --debug-benchmark-js to test without blocking
  3. Use FCrDNS: Verify bot IP addresses with verifyFCrDNS()
  4. Prefer CHALLENGE over DENY: Legitimate users can solve challenges
  5. Monitor metrics: Track rule matches via Prometheus metrics
  6. Use weights: Build gradual suspicion instead of binary decisions

Generating Rules from robots.txt

Anubis includes the robots2policy tool to automatically convert robots.txt files into Anubis policy rules.

Usage

Options

Example Output

Input robots.txt:
Generated policy:

Next Steps