Request Flow
When a request arrives at Anubis, it follows this processing pipeline:1. Initial Request Check
Every request is evaluated inlib/anubis.go:maybeReverseProxy(). The system:
- Extracts the client IP from
X-Real-Ipheader (configured by your reverse proxy) - Checks for an existing Anubis JWT cookie
- If found, validates the cookie’s integrity and expiration
Anubis requires the
X-Real-Ip header to be set by your upstream reverse proxy (nginx, Caddy, etc). Missing this header results in a misconfiguration error.2. Cookie Validation
If a cookie exists, Anubis performs JWT validation:- Signature integrity: Using Ed25519 or HMAC-SHA512
- Expiration: Tokens expire based on
ANUBIS_COOKIE_EXPIRATION - Policy rule hash: Ensures the token was issued for the currently matching rule
- Restriction header (optional): Binds the token to specific request properties
3. Policy Evaluation
When no valid cookie exists, the request goes through policy evaluation inlib/anubis.go:check():
Bot Rules
Evaluated first. Each rule can match on IP, user agent, headers, path, ASN, or GeoIP.
Thresholds
Evaluated after bot rules. Use accumulated weight from WEIGH actions to trigger challenges.
Challenge Issuance
When a policy rule returnsCHALLENGE, Anubis:
- Generates a unique challenge ID using UUID v7
- Creates random data (64 bytes) for proof-of-work
- Stores challenge metadata in the configured store backend:
- Renders the challenge page with embedded JavaScript solver
- Sets a test cookie to verify cookie support
JWT Token Generation
After successful challenge validation inlib/anubis.go:PassChallenge(), a JWT is created:
Policy Rule Hash
ThepolicyRule claim contains a hash of the bot rule configuration:
Proxying to Upstream
Once validated, the request is forwarded to your upstream application with additional headers:Cookie Management
Anubis uses two cookies:__anubis_jwt (Main JWT)
__anubis_jwt (Main JWT)
Contains the signed JWT proving the client passed a challenge.
- Expires based on
ANUBIS_COOKIE_EXPIRATION(default: 24 hours) - Can be scoped to a specific domain with
ANUBIS_COOKIE_DOMAIN - Supports SameSite policies and Partitioned cookies
__anubis_test (Cookie Test)
__anubis_test (Cookie Test)
Performance Characteristics
- Policy evaluation: O(n) where n is the number of bot rules
- JWT validation: Constant time cryptographic operations
- Challenge validation: Constant time hash comparison with
crypto/subtle - Store operations: Depends on backend (memory: O(1), bbolt: O(log n), Valkey: network latency)
DNSBL Integration
Ifdnsbl: true is configured, Anubis queries DroneBL before policy evaluation:
Next Steps
Challenges
Learn about challenge types and proof-of-work mechanisms
Policies
Understand bot detection rules and threshold configuration
Architecture
Explore component interactions and deployment patterns