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
reverseDNS(ip)- Get PTR recordslookupHost(hostname)- Get A/AAAA recordsverifyFCrDNS(ip)- Verify FCrDNSverifyFCrDNS(ip, pattern)- Verify FCrDNS with regex patternarpaReverseIP(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):Common Patterns
Allow Static Assets
Block Known Bad Actors
Protect POST Endpoints
Dynamic Load Protection
Best Practices
- Order matters: Place specific ALLOW rules before generic DENY rules
- Test expressions: Use
--debug-benchmark-jsto test without blocking - Use FCrDNS: Verify bot IP addresses with
verifyFCrDNS() - Prefer CHALLENGE over DENY: Legitimate users can solve challenges
- Monitor metrics: Track rule matches via Prometheus metrics
- Use weights: Build gradual suspicion instead of binary decisions
Generating Rules from robots.txt
Anubis includes therobots2policy tool to automatically convert robots.txt files into Anubis policy rules.
Usage
Options
Example Output
Inputrobots.txt:
Next Steps
- Challenge Configuration - Configure proof-of-work settings
- Policy Configuration - Complete policy file structure