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:
- Read flags and environment-backed settings.
- Load and validate the policy.
- Start the management server when metrics or health service is configured.
- Create the protected HTTP server and its listener.
- Mark the
anubishealth 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:
| Route | Purpose |
|---|---|
/healthz | Report whether Anubis is ready to serve traffic. |
/metrics | Export Prometheus metrics for monitoring and alerting. |
/debug/pprof/ and related routes | Provide 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 style | Operational role |
|---|---|
| systemd | Runs named instances with restart policy and managed cache, state, and runtime directories. |
| OpenRC | Runs named instances with Unix-socket defaults and supervised background execution. |
| FreeBSD rc | Runs the process with a configured user, environment, log file, and pid files. |
| Windows service manager | Reports 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
| Trigger | Consequence | Guard |
|---|---|---|
| Policy loading or listener setup fails | The 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 key | Challenges 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 invalid | The management server does not start. | Validate certificate, key, and CA files before deployment. |
Key files
| File | Why to read it |
|---|---|
| cmd/…/main.go | Shows the process lifecycle, readiness transition, listeners, health mode, and shutdown path. |
| lib/…/metrics.go | Defines the management interface for health, metrics, and optional profiling. |
| internal/log.go | Defines structured logs and request context fields. |
| lib/…/logging.go | Defines supported log sinks and file retention settings. |
| lib/…/metrics.go | Defines management listener and access-control validation. |
run/anubis@.service | Shows the systemd operating contract for named instances. |
| yeetfile.js | Shows which service files and platform packages ship with releases. |