◂ Back to README

# Docker Urutau 2 ships as **two** small container images (`linux/amd64` and `linux/arm64`, no `curl`, no shell in the probe), built from one Dockerfile: | Image | Target | What it is | Compose file | |---|---|---|---| | `urutau` | `hub` | Alpine, about 28 MB: dashboard, API, data volume, receives the probes. Reads no log file | [`docker-compose.yml`](../docker-compose.yml) | | `urutau-probe` | `probe` | `FROM scratch`, under 15 MB: only the binary, CA certificates and zoneinfo. Reads the host logs and pushes them to the hub | [`deploy/probe/docker-compose.yml`](../deploy/probe/docker-compose.yml) | ``` server 1 (probe) hub /data/coolify/proxy/logs ─:ro─► /logs/traefik /var/log/urutau ─:ro─► /logs/host ── HTTPS push ──► container urutau /etc/resolv.conf ─:ro─► /logs/resolv.conf ◄─ long-poll ──── volume urutau-data ─► /data /var/log/urutau-enforce ─rw──► /logs/enforce (only when the hub's URUTAU_ENFORCE=on) volume urutau-probe-state ────► /state (spool, positions) server 2 (probe) ── same layout ──► the same hub ``` The hub and the probes are independent containers: the hub can run on one of the monitored servers (then that server also runs a probe, as any other) or on a machine of its own. The probe opens **no port**: the connection goes out to the hub, so the monitored server needs no inbound rule. Only the dedicated `logs` directory of the proxy is mounted, never the whole `/data/coolify/proxy` (it holds `acme.json`, the TLS private keys). Both images run unprivileged (uid 10001) from a static Go binary. The hub image sets `URUTAU_BIND=0.0.0.0:8790` and `URUTAU_DATA_DIR=/data` (no log path any more; the 1.x variables stop it at start) and its `HEALTHCHECK` is `urutau healthcheck` every 30 s. The probe image sets `URUTAU_STATE_DIR=/state`, exposes no port and its `HEALTHCHECK` is `/urutau probe --check`, which reads the liveness mark of the state volume (there is no shell). To read `/var/log/urutau` (group `adm`), the probe compose file adds the host group with `group_add: ["4"]`. ## Quick start (hub) ```bash cp .env.example .env sed -i "s|^URUTAU_TOKEN=.*|URUTAU_TOKEN=$(openssl rand -base64 48 | tr -d '\n')|" .env docker compose pull && docker compose up -d # published image # or, building locally: docker compose up -d --build ``` The token needs at least 32 characters and about 128 bits of estimated entropy (length times Shannon entropy; periodic or sequential tokens are refused). `openssl rand -base64 48` is recommended (`openssl rand -hex 32` also qualifies). To keep the secret out of the environment, mount a file and set `URUTAU_TOKEN_FILE` (the probe has `URUTAU_PROBE_TOKEN_FILE`). The dashboard comes up at `http://127.0.0.1:8790` by default (`URUTAU_PUBLISH` in `.env` changes the address and port). Create a probe for each server and read the answer once: ```bash docker compose exec urutau urutau probes create web1 # prints the token (urp_...) once docker compose exec urutau urutau doctor docker compose logs urutau ``` ## Probe On each monitored server, after [preparing the host logs](#preparing-the-host-logs): ```bash cd deploy/probe cp .env.example .env $EDITOR .env # URUTAU_HUB=https://urutau.example.com URUTAU_PROBE_NAME=web1 URUTAU_PROBE_TOKEN=urp_... docker compose up -d docker compose logs probe ``` Then open the Sources page of the hub: the probe appears connected with its sources (`following`, `waiting` for a file that does not exist yet). `URUTAU_HUB` must be `https://` (a plain `http://` is accepted only for loopback and private addresses, such as `http://urutau:8790` when the hub is the `urutau` service of the same host and the probe joins the `urutau-edge` network, see the comments in the compose file). Set `TZ` to the host's time zone: the hub parses `fail2ban.log`, which has none, so it must match on both sides. While the hub is unreachable the probe keeps the batches in the `/state` volume (64 MiB by default, `URUTAU_PROBE_SPOOL_MAX`), reconnects with backoff from 1 to 60 seconds and sends them in order when the hub is back; nothing is lost or counted twice. If the spool overflows, the oldest batches are dropped and the loss is counted and shown on the Sources page. To replace a token, revoke the probe on the hub and create it again; a lost token cannot be recovered because the hub keeps only its SHA-256. The probe stays under about 20 MB of memory. ## Reading the logs (probe) These notes are about the files the **probe** mounts. - **Traefik:** the access log must be JSON and written to a dedicated directory. In Traefik's static configuration set `--accesslog=true`, `--accesslog.format=json` and `--accesslog.filepath=/traefik/logs/access.log`. On Coolify the host directory `/data/coolify/proxy` is `/traefik` inside the proxy container, so that file appears on the host as `/data/coolify/proxy/logs/access.log`, which is what the compose file mounts. In the Coolify UI open Servers, the server, Proxy, and add those three lines to the `command` list of the proxy configuration, then restart the proxy. In the same place add the headers Urutau uses to tell real visits from framed requests: `--accesslog.fields.headers.names.Sec-Fetch-Site=keep`, `--accesslog.fields.headers.names.Sec-Fetch-Dest=keep` and `--accesslog.fields.headers.names.Referer=keep`. - **auth.log and fail2ban.log:** the dedicated host directory `/var/log/urutau` is mounted read-only at `/logs/host` as a directory, because logrotate recreates these files by rename and a single-file mount would keep following the old inode. Prepare it as shown in [Preparing the host logs](#preparing-the-host-logs). The files are owned by `syslog:adm`, so the container adds the host's `adm` group (GID 4) with `group_add: ["4"]`, as the compose file does. Nothing else from the host `/var/log` is exposed. - **Read-only:** all log mounts are `:ro`. Urutau never writes to a log. (The only writable mount is `/logs/enforce`, see [Host kit](#host-kit).) - **Rotation:** the follower reopens the file when logrotate replaces or truncates it. ## Preparing the host logs The probe reads a dedicated directory, `/var/log/urutau`, instead of the whole `/var/log`. Prepare it once on each server (the original `/var/log/auth.log` stays untouched): ```bash sudo install -d -m 0750 -o syslog -g adm /var/log/urutau # rsyslog: copy sshd lines into their own file sudo tee /etc/rsyslog.d/40-urutau.conf >/dev/null <<'EOF' if $programname == 'sshd' or $programname == 'sshd-session' then { action(type="omfile" file="/var/log/urutau/auth.log" template="RSYSLOG_FileFormat" fileOwner="syslog" fileGroup="adm" fileCreateMode="0640") } EOF sudo systemctl restart rsyslog # fail2ban: write its log there too sudo tee /etc/fail2ban/fail2ban.d/urutau.local >/dev/null <<'EOF' [Definition] logtarget = /var/log/urutau/fail2ban.log EOF sudo systemctl restart fail2ban # logrotate for both files sudo tee /etc/logrotate.d/urutau >/dev/null <<'EOF' /var/log/urutau/auth.log /var/log/urutau/fail2ban.log { weekly rotate 4 compress delaycompress missingok notifempty create 0640 syslog adm postrotate systemctl kill -s HUP rsyslog.service 2>/dev/null || true fail2ban-client flushlogs >/dev/null 2>&1 || true endscript } EOF ``` If you also install the host kit, the logrotate rule above names only `auth.log` and `fail2ban.log` on purpose: with the host kit, the kit rotates `egress.log` and `probe.log` itself and logrotate refuses duplicate entries. `RSYSLOG_FileFormat` writes ISO timestamps, which is the format Urutau parses. Check the `adm` GID with `getent group adm`. Known limitation: a local user of the host can forge sshd lines with `logger -t sshd`. Urutau limits the damage (a hostile level needs a strong signal and the admin immunity lasts 24 hours), but anyone with a shell on the host is already inside your trust boundary. ## Example: Coolify Two resources. On the server that hosts the hub, a Docker Compose resource with the hub and its domain: ```yaml services: urutau: image: git.lucasrguerra.dev.br/ciberfauna/urutau:latest restart: unless-stopped environment: URUTAU_TOKEN: ${URUTAU_TOKEN} URUTAU_NAME: server-1 # the primary probe: its data is the data-dir root URUTAU_TRUSTED_PROXY: 10.250.0.0/24 TZ: UTC read_only: true cap_drop: [ALL] security_opt: ["no-new-privileges:true"] volumes: - urutau-data:/data networks: [urutau-edge] labels: - traefik.enable=true - traefik.docker.network=urutau-edge - traefik.http.routers.urutau.rule=Host(`urutau.example.com`) - traefik.http.routers.urutau.entrypoints=https - traefik.http.routers.urutau.tls=true - traefik.http.routers.urutau.tls.certresolver=letsencrypt - traefik.http.services.urutau.loadbalancer.server.port=8790 volumes: urutau-data: networks: urutau-edge: external: true ``` Then, on every server (including that one), a second Compose resource with `deploy/probe/docker-compose.yml`, with `URUTAU_HUB`, `URUTAU_PROBE_NAME` and `URUTAU_PROBE_TOKEN` in the Coolify environment. On the hub's own server the probe can use `https://urutau.example.com` or join the `urutau-edge` network and use `http://urutau:8790`. Notes: - **A network shared only with Traefik.** `--trusted-proxy` defaults to loopback only, so by default `X-Forwarded-For` is ignored. The compose file creates the `urutau-edge` network (`10.250.0.0/24`) and sets `URUTAU_TRUSTED_PROXY=10.250.0.0/24`, so only the proxy on that network is believed (any other container there could forge client IPs). Attach the proxy with `docker network connect urutau-edge coolify-proxy`, or let the labels do it as above. If the proxy sits elsewhere, set `URUTAU_TRUSTED_PROXY` to its address. - Set `URUTAU_TOKEN` in the Coolify environment. Behind the proxy the dashboard is served over HTTPS, so the session cookie is `Secure`. - Do not publish port 8790 on the host when the proxy already routes it. The domain must pass `/api/v1/probe/*` (it is the same host as the dashboard); a Cloudflare proxy in front is fine: the longest request is a 25 second long-poll. - If the Traefik access log is missing or not JSON, its source stays at zero lines or `malformed` grows on the Sources page. - Urutau needs no `tmpfs`: the root filesystem is read-only and the write targets are the `/data` volume of the hub and the `/state` volume (and, in enforce mode, `/logs/enforce`) of the probe. ## Host kit `deploy/host/` holds an optional kit that needs root on the host and gives the probe three more sources. Urutau itself never gets privileges: the probe only reads the logs the kit writes and, in enforce mode, appends decisions to a file. Run it on every server that has a probe. ```bash sudo sh deploy/host/install.sh # probe and egress logging + container map sudo sh deploy/host/install.sh --enforce # also the fail2ban jail of the second firewall sudo sh deploy/host/install.sh --probe # probe host: the kit, plus the enforce directory the probe writes sudo sh deploy/host/install.sh --probe --enforce sudo sh deploy/host/install.sh --remove # undo everything (logs are kept) ``` It is idempotent. `URUTAU_WAN` overrides the detected uplink interface and `URUTAU_UID` (default `10001`) the uid that owns the enforce directory. It needs `nft`, `rsyslog` and Docker (and `fail2ban` and `python3` for `--enforce`). | Part | What it installs | |---|---| | egress logging | nftables table `inet urutau_egress` (`/etc/urutau/egress.nft`, only logs, never drops, separate from the Docker and fail2ban tables) and the `urutau-egress.service` unit; rsyslog rule `41-urutau-egress.conf` sends the kernel lines to `/var/log/urutau/egress.log` (`URUTAU-EGRESS:`) and `/var/log/urutau/probe.log` (`URUTAU-PROBE:`); logrotate daily, 7 copies, at most 200 MB (`urutau-logrotate.timer`) | | probes | the `URUTAU-PROBE:` rule logs new inbound connections on the uplink to ports no socket listens on (at most 10 per second per source); the set of open ports is refreshed every minute from `ss`, including ports Docker publishes | | container map | `urutau-containers-map`, run by its timer (every minute) and by `urutau-containers-watch` (on every container start or network attach, so a redeploy that swaps addresses is named right within seconds), writes `/var/log/urutau/containers.map` (` `) and `/var/log/urutau/resolv.conf` (the real upstream resolvers) | | second firewall (`--enforce`) | directory `/var/log/urutau-enforce` (owned by `URUTAU_UID`, group `adm`) with `decisions.log` and `unban.log`; fail2ban filter `urutau`, action `urutau-allports` and jail `urutau` (`polling` backend, `maxretry = 1`, `bantime = 1h`, actions on `INPUT` and `DOCKER-USER`, host `ignoreip` kept); `urutau-unban.path` and `urutau-unban` apply the Unban button | The `urutau-allports` action behaves like `iptables-allports` but only drops connections the banned address starts (conntrack original direction), so replies to connections the host opened keep flowing. The egress and probe files land in `/var/log/urutau`, which the probe compose file already mounts at `/logs/host`, so the probe finds them at its defaults (`URUTAU_EGRESS=auto` turns on by itself once the file exists). For the second firewall add the mount and the variables to the compose file, start with `observe` and move to `on` when the decisions look right: ```yaml # hub (docker-compose.yml) environment: URUTAU_ENFORCE: observe # off | observe | on # URUTAU_ENFORCE_SHARE: "on" # a decision for one server is also queued for the others # probe (deploy/probe/docker-compose.yml): the /logs/enforce volume is already there ``` The decisions travel from the hub to the probe of the host (long-poll) and the probe appends them to `/logs/enforce/decisions.log`; it accepts only lines with exactly the shape of a ban or unban line. `/logs/enforce` must be writable by uid 10001 (the kit does it) and cannot be `:ro`. The probe counts a refused or unwritable command as an error, shown on the Sources page. See [configuration.md](configuration.md) for the policy and the variables. ## Geolocation database The DB-IP Lite databases are downloaded into the data volume (`/data/geo`) on first start, so the container needs outbound HTTPS to `download.db-ip.com` once, and then once a month. The Tor lists (`URUTAU_TOR_AUTO=on`) also need `check.torproject.org` and `onionoo.torproject.org` every 6 hours; with `URUTAU_TOR_AUTO=off` that is not needed. If the host cannot reach the internet, copy the two `.mmdb` files into the volume and set `URUTAU_GEO_UPDATE=0` ([configuration.md](configuration.md)). Data by [DB-IP](https://db-ip.com), CC BY 4.0. ## Several servers One hub, one probe per server, each with its own name and token. There is no peer token and no shared secret: `urutau probes create ` makes a token for one probe, only its SHA-256 stays on the hub, and `urutau probes revoke ` cuts one server off without touching the others (its data is kept). The dashboard host selector offers `all` and each probe, summaries, IP tables, the live map and incidents (`host/INC-n`) merge them, and the egress settings and map location of each probe are set on the Sources page. With `URUTAU_ENFORCE_SHARE=on` a ban decided for one server is also queued for the others. Moving from 1.x: [migration-2.0.md](migration-2.0.md). ## Hardening `read_only: true`, `cap_drop: [ALL]`, `no-new-privileges` and read-only log mounts leave the hub able to do one thing, serve and write its data volume, and the probe able to read the logs, write its `/state` volume and dial the hub (plus the decision file, only when you enable `URUTAU_ENFORCE=on`). The probe image has no shell, no package manager and exposes no port. Keep the image on a pinned tag (`X.Y.Z`) in production and `latest` only where you accept updates. ## Health and shutdown `GET /api/health` answers `{"status":"ok"}` without authentication. `urutau healthcheck` calls it locally and exits 0 when the daemon is healthy; the hub image uses it as its `HEALTHCHECK`, and the probe image uses `urutau probe --check`. On `SIGTERM` or `SIGINT` the daemon stops accepting requests (5 second grace), saves the snapshot and exits 0.