Protected request processing
Anubis receives an HTTP request, builds the context needed to assess it, and applies the configured protection policy before it reaches the protected service. The result is an allow path to the service, a challenge path for a client that must prove it is acceptable, or a rejection response.
Request processing flow
The request path connects server intake, request context, policy evaluation, and response handling. Static and Anubis-owned paths are handled locally; other paths enter protection processing before Anubis either serves a response or passes the request to the next handler.
This diagram shows the main request outcomes.
flowchart TD
A[HTTP request] --> B[Server and route selection]
B --> C[Request context]
C --> D[Policy and safety checks]
D --> E{Protection result}
E -->|Allow| F[Pass to protected service]
E -->|Challenge| G[Issue challenge response]
E -->|Deny| H[Return rejection response]
G --> I{Valid proof on later request?}
I -->|Yes| F
I -->|No| G
Request intake
The HTTP server accepts complete requests and limits how long a client can hold connection resources while sending headers. The Anubis handler then separates local endpoints from requests that need policy protection. See HTTP server and routing for the route boundary and server setup.
References: internal/http_server.go• L8-14 lib/http.go• L457-476
Request context
Request context gives later checks a trusted view of the request and a shared record for logs and metrics. It includes request-scoped logging and can add client network identity data such as ASN information. The policy path also validates the request path and requires the client address supplied by the front proxy before it makes a decision.
References: lib/anubis.go• L114-132 lib/anubis.go• L328-351 lib/anubis.go• L863-877
Protection result
The policy produces a check result with the matching rule, its action, and the accumulated weight. Rules can stop processing with an explicit allow, deny, benchmark, or challenge action; thresholds can turn the accumulated weight into a final action; otherwise the default is allow. See Policy evaluation for the decision model.
References: lib/…/checkresult.go• L9-20 lib/anubis.go• L863-946
Response paths
Anubis uses the protection result to choose the response that the client sees. A successful allow sends the request to the protected service, while a challenge creates state that a later validation request must consume before the client can continue.
Allow response
An explicit allow marks the request as permitted and sends it to the next handler without a challenge. A request with a valid proof follows the same path after Anubis verifies its token, its policy rule, and any configured request restriction.
References: lib/anubis.go• L456-461 lib/anubis.go• L385-427
Challenge response
A challenge response asks the client to complete the configured proof step instead of forwarding the request. Anubis stores challenge metadata and returns a challenge page or status-oriented response; successful validation creates the proof used by the next request. See Challenge lifecycle for issuance, validation, and single-use state.
References: lib/anubis.go• L182-228 lib/http.go• L285-395 lib/anubis.go• L615-805
Rejection response
An explicit deny or a failed protection check ends processing at Anubis and returns a configured denial or error response. A failed safety or service dependency check can also stop the request before it reaches the protected service.
References: lib/anubis.go• L337-343 lib/anubis.go• L447-487 lib/anubis.go• L490-522
Downstream request contract
Requests that pass protection carry the decision context needed by the protected service. Anubis records the selected rule and action in downstream headers, and it removes conflicting connection-token declarations so those headers remain controlled by Anubis.
The protected service therefore receives both the original request flow and a small, explicit signal about the protection result. Requests that do not pass protection never enter this downstream path.
References: lib/anubis.go• L285-325 lib/anubis.go• L424-427
Change checklist
When these files or sections are changed, remember to consider these:
- Keep route registration and the local-path dispatch rules aligned so static, API, and protected-service paths do not bypass the intended decision point.
- Keep the front-proxy client identity contract aligned with policy checks. Missing or invalid
X-Real-IPdata prevents a valid policy result. - Keep challenge rule data stable between issuance and validation. Changes to the rule hash, method, difficulty, or extensions can invalidate in-flight challenges.
- Keep downstream risk headers aligned with the allow path so the protected service does not receive stale action data.
- Keep status-only routes consistent with the normal challenge path when an external proxy needs a status response instead of an embedded page.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
Missing or invalid X-Real-IP | Policy processing stops with an internal error response. | Configure the front proxy to provide a valid client address before Anubis. |
| Invalid request path segments | The request does not reach policy evaluation or the protected service. | Reject dot segments and validate any original URI used in subrequest mode. |
| Expired, invalid, or rule-mismatched proof cookie | Anubis clears the proof and presents a new challenge. | Bind the proof to the current policy rule and validate its expiry and signature. |
| Challenge state already spent | The validation attempt is rejected and cannot create another proof. | Treat each issued challenge as single-use. |
| DNSBL lookup failure when DNSBL protection is enabled | Anubis returns a service-unavailable response. | Keep the DNSBL dependency reachable and use its cache where available. |
Key files
| File | Why to read it |
|---|---|
| lib/anubis.go | Shows the end-to-end request decision, proof-cookie checks, challenge handoff, and downstream forwarding. |
| lib/http.go | Shows the outer HTTP dispatch, challenge response rendering, and status/error responses. |
| lib/…/checkresult.go | Defines the small result passed from policy evaluation to response handling. |
| lib/…/checker.go | Shows the request data that policy checks can inspect and the path safety boundary. |
| lib/config.go | Shows how local endpoints, challenge endpoints, and the protected-service handler are connected. |
| internal/http_server.go | Defines the connection-level limits applied before request processing begins. |