Introducing a new way to review your PRs.

Read the announcement

techarohq / anubis

Weighs the soul of incoming HTTP requests to stop AI crawlers

View on GitHub

19 documents · Updated Nov 23, 2026

docs / operations-and-observability

Operations and observability

Anubis is an HTTP defense proxy that runs as a long-lived service in front of an upstream application. Its operating model separates protected traffic from management traffic so operators can start the service, check whether it is ready, collect metrics, and inspect logs without mixing those duties with user requests.

Service lifecycle

The service lifecycle covers configuration, readiness, request serving, and clean shutdown. The main process can run directly or under a platform service manager. It loads its policy before it reports itself as ready, then stops both HTTP servers with a short grace period when the process receives a termination signal. See docs/runtime-entrypoints.md for platform bootstrapping and service integration.

The normal startup sequence is:

  1. Read flags and environment-backed settings.
  2. Load and validate the policy.
  3. Start the management server when metrics or health service is configured.
  4. Create the protected HTTP server and its listener.
  5. Mark the anubis health service as serving.

This sequence makes readiness mean that the protected listener is active, not only that the process exists. A service manager can therefore delay traffic until Anubis can accept requests.

The following diagram shows the relationship between process startup, the two listeners, and shutdown.

flowchart LR
    A[Process start] --> B[Load and validate policy]
    B --> C[Start management listener]
    B --> D[Start protected HTTP listener]
    D --> E[Mark anubis serving]
    E --> F[Accept protected traffic]
    G[TERM or interrupt] --> H[Graceful shutdown]
    H --> C
    H --> D

References: cmd/…/main.go• L233-279 cmd/…/main.go• L281-335 cmd/…/main.go• L481-520

Health checks

Health checks give deployment systems a small, stable signal for process readiness. The management listener exposes /healthz, which returns 200 OK only after the anubis service reaches the serving state. Before that point it reports a server error, and an unknown health state reports a failed dependency.

The executable also provides --healthcheck. This mode calls the management endpoint and exits with failure when the endpoint cannot be reached or does not return success. Container and service probes can use this command without sending a request through the protected application path.

References: lib/…/metrics.go• L46-64 cmd/…/main.go• L110-122 cmd/…/main.go• L251-257 internal/health.go• L10-24

Management interface

The management interface is a separate HTTP server for health and operational data. It can listen on TCP or a Unix socket. Operators can protect it with TLS, mutual TLS, or basic authentication when the endpoint must cross a trust boundary.

The interface exposes these operational routes:

RoutePurpose
/healthzReport whether Anubis is ready to serve traffic.
/metricsExport Prometheus metrics for monitoring and alerting.
/debug/pprof/ and related routesProvide Go runtime profiles when debug mode is enabled.

The debug routes are optional and belong on a restricted management listener. The metrics endpoint can use TLS and client certificate checks or basic authentication. This lets an operator keep health and telemetry available without exposing them on the public traffic listener.

References: lib/…/metrics.go• L35-64 lib/…/metrics.go• L66-107 lib/…/metrics.go• L30-37

Logging

Logging records service state and request context in structured JSON. The default sink is standard output or standard error through the service environment. A file sink is also supported with limits for file size, age, backup count, and compression.

The logger carries request fields such as host, method, path, user agent, and forwarded address. These fields connect a protection decision or upstream error to the request that caused it. The HTTP server also filters common client-disconnect messages so normal cancellations do not hide useful failures.

Log level can be set at startup, while policy logging settings can take precedence after the policy loads. Production operators should route the selected sink to the platform log system or to a managed file path with suitable retention.

References: internal/log.go• L13-46 internal/log.go• L49-71 lib/…/logging.go• L16-26 lib/…/logging.go• L59-65 lib/…/logging.go• L116-124

Metrics and telemetry

Metrics turn request protection and supporting services into time-series data for dashboards and alerts. Prometheus scrapes the management server rather than the protected listener. The metrics layer is shared by the main request path and subsystems such as challenges and GeoIP enrichment, so operators can relate traffic outcomes to service work.

Useful telemetry questions include:

  • Is Anubis ready and accepting traffic?
  • Are challenge checks taking longer or failing more often?
  • Is request volume or upstream error volume changing?
  • Are enrichment or storage services adding delay?

The telemetry child page should describe metric names and subsystem-specific signals. Keep the management endpoint access-controlled when its labels or values could reveal request or deployment details.

References: lib/…/metrics.go• L26-33 lib/…/metrics.go• L46-47 lib/…/metrics.go• L120-131 lib/…/metrics.go• L1-19

Production packaging

Release packaging supplies the executable together with service definitions and platform defaults. Linux packages include a systemd template and environment file. Linux tarballs also include an OpenRC service. FreeBSD packages include an rc script, while Windows installers integrate with the Windows service manager and prepare the machine-wide configuration directory.

The service definitions provide the operating contract around the same executable:

Deployment styleOperational role
systemdRuns named instances with restart policy and managed cache, state, and runtime directories.
OpenRCRuns named instances with Unix-socket defaults and supervised background execution.
FreeBSD rcRuns the process with a configured user, environment, log file, and pid files.
Windows service managerReports start only after Anubis is serving and maps stop requests to graceful cancellation.

The package layer does not replace application configuration. It gives each platform a safe way to supply that configuration and keep the process under supervision. Read docs/runtime-entrypoints.md for the detailed entrypoint and service conventions.

References: yeetfile.js• L17-68 run/anubis@.service• L1-20 run/…/anubis.initd• L1-35 run/anubis.freebsd• L1-71 cmd/…/service_windows.go• L266-383

Operational boundaries

The public listener serves protected application traffic. The management listener serves health and telemetry. Keeping these listeners distinct allows a load balancer to use /healthz without passing through bot protection and lets monitoring scrape metrics without changing user-facing routes.

Operators must preserve the boundary when placing Anubis behind a proxy or service mesh. The management listener needs its own address, network policy, and authentication plan. A Unix socket can limit access to local agents, while TCP with TLS or authentication supports remote monitoring.

References: cmd/…/main.go• L43-76 cmd/…/main.go• L317-335 lib/…/metrics.go• L39-80

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep --healthcheck, /healthz, and the serving-state transition aligned so container and platform probes do not report false readiness.
  • Keep management listener changes aligned with TLS, client certificate, and basic-auth validation so a configured security mode cannot start with incomplete credentials.
  • Keep service package defaults aligned with the executable's bind and metrics settings, especially when an instance uses Unix sockets.
  • Keep log sink and file-rotation changes aligned with service-manager permissions and platform-specific log paths.

Important failure modes

TriggerConsequenceGuard
Policy loading or listener setup failsThe process exits before it reports readiness.Validate policy and listener settings during startup.
Management listener is unreachable--healthcheck fails and deployment systems can mark the instance unhealthy.Give probes the management address and allow that path through local network policy.
Persistent storage runs without a stable signing keyChallenges become invalid after restart and can behave inconsistently across replicas.Set one supported signing key before using persistent state.
Metrics TLS files or client-auth CA are invalidThe management server does not start.Validate certificate, key, and CA files before deployment.

Key files

FileWhy to read it
cmd/…/main.goShows the process lifecycle, readiness transition, listeners, health mode, and shutdown path.
lib/…/metrics.goDefines the management interface for health, metrics, and optional profiling.
internal/log.goDefines structured logs and request context fields.
lib/…/logging.goDefines supported log sinks and file retention settings.
lib/…/metrics.goDefines management listener and access-control validation.
run/anubis@.serviceShows the systemd operating contract for named instances.
yeetfile.jsShows which service files and platform packages ship with releases.