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 / runtime-entrypoints

Runtime entrypoints and service integration

Anubis is a command-line HTTP defense proxy. It accepts traffic from a front proxy, applies the configured protection flow, and sends approved traffic to an upstream service. This page explains how the command starts in each supported run mode and how package, service, and container tools provide its runtime settings. See also Operations and observability.

Anubis command

The cmd/anubis command is the main runtime entrypoint. It reads settings from flags and the process environment, loads policy data, starts the HTTP and metrics listeners, and stops cleanly when the process receives a shutdown signal.

The command also provides short-lived modes for operators and package tools:

  • --version prints the running Anubis version.
  • --healthcheck checks the local health endpoint and exits with success or failure.
  • --extract-resources writes embedded policy and web resources to a directory.
  • --windows-bootstrap-config prepares the Windows service configuration and exits.

The normal mode builds the upstream proxy from --target, then exposes the protected HTTP service. The target can be an HTTP URL or a Unix socket. The listener and metrics endpoint can use TCP or Unix sockets, so a front proxy can connect through the local network stack or through a protected file path.

This diagram shows the command's high-level startup path.

flowchart TD
    A[Anubis command] --> B[Platform startup hook]
    B --> C[Read flags and environment]
    C --> D{Operator mode?}
    D -->|Version, health, or resource export| E[Perform action and exit]
    D -->|No| F[Load policy and runtime settings]
    F --> G[Create upstream and metrics services]
    G --> H[Open HTTP listener]
    H --> I[Serve protected requests]
    I --> J[Receive stop signal]
    J --> K[Graceful shutdown]

References: cmd/…/main.go• L43-95 cmd/…/main.go• L233-279 cmd/…/main.go• L281-345 cmd/…/main.go• L471-520

Platform startup

Anubis keeps the core run path common across operating systems. Platform hooks prepare the process before the shared command parses settings, then the platform service wrapper can take control of the same run function.

Unix service startup

On non-Windows systems, the platform hooks are no-ops. The operating system service manager starts the command as a normal process, and Anubis handles signals directly. This keeps the service contract in the unit or init script while the command owns listener setup and graceful stop behavior.

References: cmd/…/service_other.go• L1-12 cmd/…/main.go• L233-279

Windows service startup

On Windows, the command supports both an interactive run and a Windows Service Control Manager run. A service process first loads its machine configuration from %ProgramData%\Techaro\Anubis, redirects early startup logs, and then reports Running only after Anubis reports a serving health state. A stop or shutdown request cancels the shared run context.

The MSI installer can start a separate bootstrap mode. That mode copies missing environment and policy templates into the live data directory, keeps existing administrator settings, and grants the Anubis service access to the directory. This makes installation and upgrade separate from normal request serving.

References: cmd/…/service_windows.go• L25-84 cmd/…/service_windows.go• L266-383 cmd/…/bootstrap_windows.go• L48-110 run/…/anubis.wxs• L40-74 run/…/anubis.wxs• L107-127

Service integration

Service definitions supply process ownership, restart behavior, identity, and runtime paths. They do not replace Anubis configuration. The command remains the source of truth for proxy behavior, listener creation, policy loading, and health state.

systemd instances

The systemd unit is a template, so one host can run separate Anubis instances. Each instance reads etc/…/<instance>.env, runs with a dynamic service user, and receives managed cache, state, and runtime directories. systemd restarts the process after a failure and keeps the service enabled through the normal multi-user target.

References: run/anubis@.service• L1-20

OpenRC instances

The OpenRC script also uses instance names from the service name. Its defaults favor Unix sockets for the protected listener and metrics endpoint, with environment settings available for TCP addresses, the upstream target, challenge difficulty, extra options, and the service account. The script creates a per-instance runtime directory before start and refuses to start without an instance suffix.

References: run/…/anubis.initd• L1-35 run/…/anubis.confd• L1-24

FreeBSD services

The FreeBSD rc script runs Anubis under the www account by default and places its log and pid files under the system runtime and log paths. Administrators can enable the service and override the binary, arguments, user, group, and environment file through rc configuration.

References: run/anubis.freebsd• L1-24 run/anubis.freebsd• L26-71

Front proxy connection

A front proxy must use the same listener address and network type that Anubis exposes. A mismatch leaves the front proxy unable to reach Anubis or can route traffic around the protection layer. The documented Nginx setup uses a Unix socket and forwards the original host and client address before passing the request to Anubis.

References: docs/…/upstream-anubis.conf• L1-16 docs/…/conf-anubis.conf• L1-9

Container build tooling

The container path builds a multi-platform image from the cmd/anubis entrypoint. The npm run container script first creates the embedded web and WebAssembly assets, then runs cmd/containerbuild, which validates image tags and invokes ko with the repository, version, source timestamp, labels, and annotations.

Production image builds publish to the configured registry on branch and release events. Pull request builds use a temporary pull-request image name. Both paths use the same asset build and container build command, so a local or CI image represents the same runtime artifact.

References: package.json• L11-24 cmd/…/main.go• L17-26 cmd/…/main.go• L28-120 .github/…/docker.yml• L19-88 .github/…/docker-pr.yml• L13-64

Runtime environment

Anubis treats flags and environment variables as two forms of the same runtime configuration. The command reads environment values before normal flag parsing, so service managers and containers can provide settings without changing the executable. Important settings include the HTTP bind address, bind network, metrics bind address, metrics network, upstream target, policy file, signing key, and public URL.

The runtime contract has these main conventions:

  • The HTTP listener defaults to TCP on :8923.
  • The metrics listener defaults to TCP on :9090.
  • The upstream target defaults to http://localhost:3923.
  • A Unix socket target is supported for local upstream services.
  • A persistent state store needs a stable signing key if challenges must survive a restart.
  • The externally reachable URL is separate from the local bind address and is used when Anubis builds redirect URLs.

Service packages add one more convention: environment files hold deployment-specific values, while the service definition holds process lifecycle and file-system permissions. On Windows, a real process environment value takes precedence over the installed anubis.env file.

References: cmd/…/main.go• L43-95 cmd/…/main.go• L233-257 cmd/…/main.go• L281-344 cmd/…/service_windows.go• L57-84

Change checklist

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

  • Keep listener defaults and service-manager socket defaults aligned with front-proxy examples.
  • Keep environment names, flag names, and the Windows template in sync when adding or renaming a runtime setting.
  • Keep the container tag and repository contract aligned with both release and pull-request workflows.
  • Keep Windows bootstrap paths aligned with the MSI directory layout and the service account permissions.
  • Keep health readiness behavior aligned with service managers that wait for a serving state.

Important failure modes

TriggerConsequenceGuard
Front proxy uses a different bind address or socket typeRequests cannot reach Anubis or bypass itMatch the proxy upstream with the Anubis bind settings
Persistent state runs without a stable signing keyExisting challenge tokens become invalid after restartSet one supported signing key through the runtime environment
Windows service cannot read its data directoryThe service fails before it can load settings or write logsRun the installer bootstrap and preserve service-directory access
Container tags are empty or use a different repository than the requested imageThe image build stops before publishingSupply matching metadata tags and repository settings
An OpenRC template is started without an instance nameThe service refuses to startCreate and start an instance link such as anubis.site

Key files

FileWhy to read it
cmd/…/main.goDefines the shared command modes, runtime settings, listener setup, health state, and shutdown path.
cmd/…/service_windows.goShows Windows service startup, readiness reporting, stop handling, and early log setup.
cmd/…/bootstrap_windows.goDefines how the Windows installer creates and preserves live configuration.
cmd/…/main.goDefines image metadata, pull-request image handling, and the ko build contract.
run/anubis@.serviceDefines the systemd instance lifecycle and managed runtime directories.
run/openrc/anubis.initdDefines OpenRC instance startup and default socket layout.
run/anubis.freebsdDefines the FreeBSD service contract and administrator overrides.
run/windows/anubis.wxsDefines MSI service installation, upgrades, templates, and bootstrap invocation.
docs/docs/admin/environments/nginx/upstream-anubis.confShows how a front proxy connects to the Anubis listener.