# Multi-Node Fleet Management

> [!NOTE]
>
> Deze pagina is nog niet vertaald. Je leest de Engelse versie.

For power users running services across multiple servers, CashPilot supports a federated architecture where a single UI aggregates data from workers deployed on each server.

Each Docker host runs one CashPilot worker, under one dashboard. A worker manages every container on its host that carries CashPilot's labels, so a second CashPilot install on the same host would see and control the first one's earners ([One CashPilot per Docker host](<https://geiserx.github.io/CashPilot/nl/getting-started/index.md#prerequisites>)).

## Topology

```
graph TB
    UI[CashPilot UI<br>Port 8080<br>Dashboard + Earnings + Catalog]

    W1[Worker: server-a<br>Port 8081<br>Bandwidth services]
    W2[Worker: server-b<br>Port 8081<br>Storj + Compute]
    W3[Worker: server-n<br>Port 8081<br>DePIN services]

    W1 -->|Heartbeat every 60s| UI
    W2 -->|Heartbeat every 60s| UI
    W3 -->|Heartbeat every 60s| UI

    UI -->|Deploy/Stop/Restart| W1
    UI -->|Deploy/Stop/Restart| W2
    UI -->|Deploy/Stop/Restart| W3

    W1 --- D1[Docker Engine]
    W2 --- D2[Docker Engine]
    W3 --- D3[Docker Engine]
```

## Worker Communication

Workers use **REST HTTP** to communicate with the UI:

- **Heartbeats** (worker → UI): Every 60 seconds, each worker POSTs to `/api/workers/heartbeat` with its container list, system info, and status.
- **Commands** (UI → worker): The UI sends deploy/stop/restart/remove requests to the worker's HTTP API (port 8081).

Workers must be reachable from the UI for commands. The UI must be reachable from workers for heartbeats.

A worker can add [LAN miner readings](<https://geiserx.github.io/CashPilot/nl/mining-devices/index.md>) to its heartbeat. Fleet shows the last reading from each miner you list on that worker.

### Importing earnings a client collected on its own

`POST /api/workers/earnings-import` lets a client that has been reading a provider account by itself (CashPilot Desktop, typically, before it was paired) hand that history to the UI, so the fleet view shows the complete picture rather than starting from the day of pairing.

```
POST /api/workers/earnings-import
Authorization: Bearer <this worker's own key, not the shared enrollment key>
Content-Type: application/json

{
  "client_id": "desktop-laptop",
  "readings": [
    {"slug": "honeygain", "balance": 12.4, "date": "2026-07-01", "currency": "USD"},
    {"slug": "mysterium", "balance": 88.0, "date": "2026-07-01", "currency": "MYST", "fx_rate_usd": 0.41}
  ]
}
```

It answers:

| Status | Meaning |
| --- | --- |
| `200` | `{"status": "ok", "imported": N, "skipped": [...], "source": "<client_id>"}` |
| `400` | `client_id` was missing or blank |
| `401` | the key is wrong or revoked |
| `403` | this worker is not fully enrolled yet; send a heartbeat first, then retry |
| `422` | The body contains an invalid reading or more than 2000 readings. Each date must be a real `YYYY-MM-DD` day on or before today in UTC. The `balance` and any supplied `fx_rate_usd` must be finite. |

Three things about it are deliberate:

- **Each client's readings are stored under their own source, not merged with the server's.** Earnings are clamped deltas between consecutive readings of the same balance, so interleaving two samplers of one account makes every apparent drop clamp to zero and understates the total. Separate series are differenced separately and then summed.
- **The source is taken from the authenticated worker, never from the request body.** Otherwise any enrolled client could write into another's history, or into the server's own.
- **Only a fully enrolled worker may import.** A caller still presenting the shared enrollment key gets `403` with instructions to heartbeat first: every worker holds that key, and this writes durable money data.

Re-sending the same day updates it rather than appending, so a retried or repeated import is safe.

`date` must be `YYYY-MM-DD` and a real calendar day. It is not free text: both delta readers order by it, so a differently shaped date sorts into the wrong place in its own series and the readings either side then difference against the wrong neighbour, silently and only in the earned figure. A request may carry at most **2000 readings**; send larger histories in chunks.

`balance` and `fx_rate_usd` must be finite. JSON has no `NaN` or `Infinity`, but Python's parser accepts them, and one `NaN` balance poisons every earned figure taken from that series: every comparison against it is false, so the clamp misbehaves silently and the account total becomes `NaN`. They are rejected with `422`.

Unknown slugs come back in `skipped` as a **distinct, sorted** list, so a year of one unrecognised platform is reported once rather than 400 times.

## Setting Up the Fleet

### Main server (UI + local worker)

Use `docker-compose.fleet.yml` on your main server to run both the UI and a local worker:

```
docker compose -f docker-compose.fleet.yml up -d
```

### Adding remote workers

On each additional server, deploy only a worker pointing back to the UI, with its Docker socket proxy. `docker-compose.worker.yml` is that file:

```
curl -fsSLO https://raw.githubusercontent.com/GeiserX/CashPilot/main/docker-compose.worker.yml
cat > .env <<EOF
CASHPILOT_UI_URL=http://main-server:8080
CASHPILOT_API_KEY=your-shared-api-key
CASHPILOT_WORKER_NAME=server-b
CASHPILOT_WORKER_URL=http://server-b:8081
CASHPILOT_WORKER_BIND_ADDR=100.x.y.z
EOF
docker compose -f docker-compose.worker.yml up -d
```

`CASHPILOT_UI_URL` is the UI's published host port (`CASHPILOT_UI_PORT`). The worker must reach the UI, and the default UI listens only on 127.0.0.1. On the main server, set `CASHPILOT_BIND_ADDR` to its LAN or Tailscale address ([configuration](<https://geiserx.github.io/CashPilot/nl/configuration/index.md#compose-level>)). `CASHPILOT_WORKER_BIND_ADDR` is this server's private or VPN address, never `0.0.0.0` or a public IP. To use the in-app update, also add `CASHPILOT_COMPOSE_DIR=$PWD`. It is opt-in because it lets containers bind the compose folder through the proxy, which weakens it ([what that costs](<https://geiserx.github.io/CashPilot/nl/security-defaults/index.md#docker-socket-proxy>)). Without it, update the worker with `docker compose pull && docker compose up -d`.

> [!IMPORTANT]
>
> **CASHPILOT\_WORKER\_URL**
>
> Set this to the address the UI should use to reach this worker (e.g. its LAN IP or Tailscale MagicDNS name, port 8081). Without it, the worker auto-detects its own outbound IP, which inside a container is often the Docker bridge address -- unreachable from the UI on another host.

> [!IMPORTANT]
>
> **API Key**
>
> The `CASHPILOT_API_KEY` must be identical on the UI and all workers. It is the **enrollment key** each worker uses on first contact; after that, each worker uses its own automatically-issued key.

## Why the UI and worker have separate data directories

The shipped compose files give each its own `/data` volume (`cashpilot_data` for the UI, `cashpilot_worker_data_owned` for the worker), and that is a security boundary, not tidiness.

The worker drives Docker. With the raw socket **that is root on the host**: anything that can talk to it can start a privileged container and read any file on the machine. The shipped compose files put a [socket proxy](<https://geiserx.github.io/CashPilot/nl/security-defaults/index.md#docker-socket-proxy>) in between, which refuses that and, with owner isolation, keeps the worker to the containers and volumes it created, so it cannot read the UI's files or mount its volume ([what it can still reach](<https://geiserx.github.io/CashPilot/nl/security-defaults/index.md#docker-socket-proxy>)). The UI's `/data` holds `cashpilot.db` and `.fernet_key`: the credential store and the only key that can decrypt it.

Keeping them apart means a compromised or misbehaving worker cannot simply read every provider password you have entered. It does not make the worker safe to expose (a worker with the Docker socket is as privileged as the host, which is why its API binds to loopback by default), but it does stop one component's blast radius from automatically including the other's secrets.

**`/fleet` is shared, deliberately.** It holds only the enrolment key, which both sides need by definition.

> [!WARNING]
>
> **Do not consolidate them**
>
> Merging the two into one volume is the obvious simplification when tidying a compose file, it looks harmless, and it silently removes the boundary. `tests/test_beads_batch_69.py` fails if anyone does, including if the UI ever gains the Docker socket, which is the premise the whole argument rests on.

## Authentication

CashPilot uses **per-worker fleet keys** (since v1.0.0). The shared `CASHPILOT_API_KEY` is only a bootstrap/enrollment credential; each worker then gets its own key.

- Set `CASHPILOT_API_KEY` on the UI and all workers (or let the UI + co-located worker auto-generate one via the `/fleet` volume).
- **Enrollment:** a worker's first heartbeat authenticates with the shared key. The UI issues that worker its own unique key (stored encrypted on the UI, and returned once). The worker persists it under its private `/data`.
- **After enrollment:** the worker authenticates every heartbeat with its own key, and the UI calls that worker with the same key. The shared key **no longer works** for an enrolled worker, so a leaked worker key only affects that one worker, and no worker can impersonate another. The worker sends its next heartbeat at once, with its own key, and keeps taking the shared key until a heartbeat signed with its own key lands, so commands work from the moment it enrols.

The fleet key is **never sent to the browser on page load**. The fleet dashboard reveals it only on an explicit, owner-only action (the **Reveal API Key** button), and copy-to-clipboard fetches it the same way.

> [!WARNING]
>
> **Security**
>
> Keys grant container-management access: treat them as sensitive credentials, and never expose worker APIs (port 8081) to the public internet. See the [v1.0.0 upgrade steps](<https://github.com/GeiserX/CashPilot/blob/main/UPGRADING.md#v100-per-worker-fleet-keys>) if you are moving an existing fleet.

### Plain HTTP only on your own network

Every heartbeat carries the worker's key, and every command from the UI carries it too. That key deploys containers on the worker. So neither side sends it over plain `http://` to an address that could be on the public internet:

- The worker sends nothing to a `CASHPILOT_UI_URL` that is `http://` to a public host.
- The UI sends no command to a worker whose `CASHPILOT_WORKER_URL` is `http://` to a public host.

`https://` works with any host. Plain `http://` works only with a host that cannot be on the public internet:

- `localhost`, or an IP in `127.0.0.0/8`, `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `169.254.0.0/16` or `100.64.0.0/10` (Tailscale)
- IPv6 `::1`, `fc00::/7` or `fe80::/10`
- a single-label name, such as `cashpilot-ui` or `nas`
- a name under `.local`, `.lan`, `.home.arpa`, `.internal` or `.ts.net`

CashPilot Desktop and the Android app use the same list. The check reads the host as written in the URL and never asks DNS, so a public name such as `nas.example.com` counts as public even when your router resolves it to a LAN address. Use the box's IP or one of the names above instead.

When a URL is refused, CashPilot says why and what to change:

- **A refused `CASHPILOT_UI_URL`.** The worker logs an error once at start, its status page on port 8081 shows the reason, and `/api/health` answers `503` with the reason in `error`, so Docker marks the container unhealthy. The worker does not appear in the UI until you fix the URL and recreate the container.
- **A refused worker URL.** The worker still reports in. On the Fleet page its row has a **plain HTTP refused** flag with the reason, and every deploy, start, stop or logs request to it fails with the same message.

To fix it, give the box an `https://` address (a reverse proxy with a certificate in front of it), or reach it through its LAN or Tailscale address.

## Fleet Dashboard

The **Fleet** page lists every box:

- each worker with its system, worker version and last report, shown in red once it stops reporting;
- its wall power draw in watts, which the [Running costs](<#running-costs>) block weighs against what the machine earned in the last 30 days;
- the containers it reported or, for a phone running the [Android app](<https://github.com/GeiserX/CashPilot-android>), its earning apps. A box that stopped reporting keeps its last known list, greyed out;
- **Check isolation** on Docker workers that support it ([what it tests](<https://geiserx.github.io/CashPilot/nl/isolation-check/index.md>)) and **Remove**;
- **Add a box** at the bottom, with the environment variables for the next worker. A computer with [CashPilot Desktop](<https://github.com/GeiserX/CashPilot-Desktop>) joins with the same block: pick **Join my CashPilot** (on first run, or in Settings under **How this computer runs**) and paste it into **Paste from Add a box**. A joined Desktop shows the **Desktop** tag. You deploy services to it, and use Stop, Restart, Logs and **Stop on all servers** on its copies, as on a Docker worker, while its dashboard switch **can start and stop services on this computer** is on. The switch is on by default on a new install of Desktop 2.0, and off after an upgrade from Desktop 1.x. A Desktop takes these commands only from CashPilot 3.0 or later. CashPilot sends it only the key it gave that Desktop when it joined, never the shared key. The Desktop runs the image its own catalog pins, one copy per service, and refuses to delete data that cannot be recovered. Before a deploy, CashPilot asks the Desktop which container the deploy would replace. If a container holds the service's name, even one that no CashPilot made, CashPilot asks you before it replaces it, and the Desktop replaces only the container you approved. A Desktop without this check gets no deploy, and CashPilot asks you to update it to 2.0.0 or newer. When it sends no address to take commands at, it shows **Desktop, reports only**: with the switch off, on Windows before you allow it through Windows Firewall on its dashboard, or with no private network or Tailscale address. It reports what runs there, its buttons on the dashboard are off and say why, and you add services in its own app. A deploy asks it for one copy only; copies you add on that computer stay there. A deploy through a proxy is refused for a Desktop: add that copy in CashPilot Desktop on that computer. The update card lists Docker workers only. You update a Desktop by hand from its [releases page](<https://github.com/GeiserX/CashPilot-Desktop/releases>). A deploy that names no worker still goes to the one Docker worker.

![The Boxes table on the Fleet page: three Linux boxes reporting, one offline box with its last known containers greyed out, and an Android phone listing its earning apps](<https://geiserx.github.io/CashPilot/nl/images/screenshots/fleet-phone.png>)

Starting, stopping, restarting and viewing logs happen on the **Dashboard**. There, a service running on several workers shows an expandable row with one sub-row per instance; the main row shows the average CPU and memory (prefixed with `~`), and each sub-row its own figures and buttons.

### Running costs

The **Running costs** block shows earnings for the last 30 days and estimates electricity costs for fleet machines and tracked devices. Enter your electricity price and currency at the top of the block. Set each machine's wall draw in the Boxes table: a machine without one says so in its **Power draw** column, with **Set in Boxes** to jump to the field.

- **Tracked devices.** If you track a mining pool or GPU service, enter the total wall draw of all equipment on that account in its **Device** row. Leave the field empty if you do not know the draw. The electricity cost and net stay unknown. Pool figures show what accrued during the period.
- **Break-even tariff.** If you pay per kWh and CashPilot knows the machine's draw and earnings, its row says "Earns more than its electricity below 0.069 EUR/kWh". That is the electricity price at which the machine's earnings exactly cover its power. If you pay less, it makes money. If you pay more, it costs you money. The line shows before you enter a price, in the currency of your tariff setting (in USD when no exchange rate is available). With a price entered it adds "(you pay 0.250)" so you can compare. A machine that earned nothing in the window loses money at any price, so its break-even is 0. A machine whose services have no earnings reading at all (no collector, no credentials or no exchange rate) shows no break-even, because CashPilot does not know what it earned.
- **Every figure rests on the watts you typed.** CashPilot measures no power. Read the draw from a plug meter or the machine's spec, and expect the figures to be only as good as that number.
- **Per-service figures start from the same watts.** CPU-based services, including CPU miners, split the machine's draw by CPU use. Their shares never add up to more than the typed draw. Without that value, the split falls back to a 65 W estimate or a configured host TDP. `/api/earnings/net` shows a service's break-even when its CPU share is at least 5 W or you enter its whole-device draw.
- **Fixed-price hosting.** Select **Not billed per kWh** in the machine's Boxes row and save. Fleet leaves out its electricity cost and break-even tariff. Clear the checkbox to restore these figures from the saved draw. Enter the hosting fee as its rent, or Fleet shows no net for the machine.
- **Rent.** If you rent the machine, such as a VPS or a rented server, type its monthly rent in its Boxes row and save. The field shows the currency it uses: your tariff's currency, or your display currency if you have set no tariff currency or price. The rent is saved with that currency and keeps it, so a later change to the tariff currency does not change what a saved rent means. To change a rent's currency, clear the rent and save, set the tariff currency, then type the rent again and save. To pick a currency without a price per kWh, type only the currency in the tariff setting and save. If a price is stored and you empty the price field, that save removes the price, so electricity is no longer counted. Fleet takes the rent off what the machine earned: gross − rent = net. A machine with a rent and a per-kWh bill pays both: gross − (rent + electricity) + heat = net. A row with a rent shows no break-even tariff, because that figure assumes electricity is the only cost. A machine billed per kWh with no price or draw yet counts its rent, and its net says it is before electricity. Until CashPilot reads what a rented machine earns, its row gives no verdict, and the fleet total leaves it out of the net. With no exchange rate to USD, the machine's cost shows as unknown. Per-service figures leave the rent out, because it belongs to the whole machine. Leave the field empty when there is no rent.
- **Heat credit.** A miner turns all the power it draws into heat. If that heat replaces heating you pay for, press the button in its **Heat** column (it names what the heat replaces, or "None") to open the heat form under its row. Pick what it replaces (electric resistive heating, a heat pump with its COP, or a fuel with the cost of one kWh of heat in your tariff currency) and tick the months you heat. No months are ticked for you, and a heat source without months is not saved. The credit is part of the net, and the **Net** column shows it under the figure as "incl. heat": gross − electricity + heat = net. A kWh of heat is never worth more than your tariff, because a resistive heater could always make it at that price, so the credit never exceeds the electricity cost. A machine on fixed-price hosting gets no credit. The credit counts the days of the last 30 that fall in your ticked months. The break-even line adds the price below which it pays in your heating months. The credit assumes all its heat replaces heating you pay for during those months. If the room overheats, that heat is wasted and the credit is too high.
- **Expected earnings (Bitcoin pools).** When a Bitcoin pool reports your hashrate with the balance (today OCEAN, over its last 5 minutes), the pool's row adds what that hashrate should earn in 30 days. Next to it is what the pool credited, compared with the estimate for the same days: a pool tracked for 3 days is compared over those 3 days, never against the 30-day figure. Days next to a reading with no exchange rate count in neither figure. CashPilot works it out from the network difficulty and the average reward of the last 144 blocks, read from the Bitcoin endpoint of the [Payouts lookup](<https://geiserx.github.io/CashPilot/nl/onchain/index.md#choose-where-the-lookup-goes>) (mempool.space by default). It is an estimate before the pool's fee, not money the pool owes you: luck, the fee and how the pool shares rewards move the real figure up or down in any month. It uses the pool's latest reading, so a short burst or dip in hashrate moves it too. If that read fails, the row shows no estimate until the next good read. If the network figures cannot be read, the row says so and shows no expected amount. Other coins get no estimate yet.

## Budgeting a small box

Earners differ a lot in what they use. Measure before you decide what runs where, rather than spreading every service over every box.

**The usual heavy ones.** The catalog's memory caps (`docker.resources.mem_limit` in each `services/*/*.yml`) are limits, not usage, but they show the spread:

| Kind | Examples | What it costs |
| --- | --- | --- |
| Storage nodes | Sia (hostd), Storj | The highest memory caps (4 GB and 2 GB), steady disk I/O, a large data disk |
| Relays and VPN exits | Anyone Protocol, Mysterium | Memory caps of 1.5 GB and 768 MB, CPU that rises with traffic. Mysterium's published UDP ports also run `docker-proxy` processes outside its container ([what each port costs](<https://geiserx.github.io/CashPilot/nl/mysterium-fence/index.md#what-each-port-costs>)) |
| GPU compute | Salad, Vast.ai, io.net | The whole GPU, plus CPU and memory while a job runs |
| Most bandwidth earners | Honeygain, EarnApp, Traffmonetizer, Repocket | Memory caps of 128 to 256 MB |

A [proxied copy](<https://geiserx.github.io/CashPilot/nl/proxies/index.md>) adds its earner; the box runs one tunnel container per proxy, shared by every copy through it.

**Measure on the box.** The **Dashboard** shows each container's CPU and memory, refreshed every few minutes, for the services it reports; earners you started outside CashPilot may not show there. For a snapshot of everything at once:

```
docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}'
```

It lists every running container, including earners you started outside CashPilot. CPU is per core: `100%` is one full core. Take a few snapshots at different times of day, since bandwidth earners and exits are busiest when someone is buying traffic. `docker stats` counts only what runs inside containers, so also look at the host as a whole (`free -m`, `uptime`) and at the CashPilot UI and worker themselves ([Memory](<https://geiserx.github.io/CashPilot/nl/configuration/index.md#memory>)).

**Then decide.** Put storage nodes and GPU work on the machine with the disk or the card. Keep a small box to the light earners. When what you want from a small box at another site is its IP rather than its hardware, make it an exit node instead of a worker ([A second site as an exit node](<https://geiserx.github.io/CashPilot/nl/proxies/index.md#a-second-site-as-an-exit-node-instead-of-a-worker>)).

## Cross-Subnet Workers

If the worker and UI are on different subnets (e.g., connected via Tailscale):

1. The UI server must advertise its subnet: `tailscale set --advertise-routes=<UI-subnet>`
2. The worker server must accept routes: `tailscale set --accept-routes=true`
3. The worker uses the UI's LAN IP in `CASHPILOT_UI_URL` (not the Tailscale IP)

## Offline Handling

If a worker goes offline (no heartbeat for 180 seconds; 45 minutes for an Android phone, which reports every 15 minutes):

- The UI marks the worker as offline
- Historical earnings and health data is retained
- The worker reconnects automatically when back online
- Container status updates resume immediately after reconnection

## Environment Variables Reference

### UI

| Variable | Default | Description |
| --- | --- | --- |
| `CASHPILOT_API_KEY` | *(auto-generated via /fleet volume)* | Shared secret for worker authentication |
| `CASHPILOT_SECRET_KEY` | *(auto-generated)* | Signing key for login sessions. Persisted at `/data/.secret_key`. **Does not encrypt credentials** |
| `CASHPILOT_ENCRYPTION_KEY` | *(auto-generated)* | Fernet key encrypting stored credentials at rest. Persisted at `/data/.fernet_key`; adopted only when that file is absent |
| `CASHPILOT_ADMIN_API_KEY` | \-- | Optional separate key granting full owner access (for integrations) |
| `CASHPILOT_READONLY_API_KEY` | \-- | Optional read-only key for dashboards. Reporting GETs only; refused everywhere else |
| `CASHPILOT_CAPTCHA_PROVIDER` | \-- | Optional CAPTCHA on the sign-in page: `turnstile`, `hcaptcha` or `recaptcha` (v2 checkbox). Empty means off. See [Protect the sign-in page with a CAPTCHA](<https://geiserx.github.io/CashPilot/nl/security-defaults/index.md#protect-the-sign-in-page-with-a-captcha>) |
| `CASHPILOT_CAPTCHA_SITE_KEY` | \-- | The provider's site key. Required when `CASHPILOT_CAPTCHA_PROVIDER` is set |
| `CASHPILOT_CAPTCHA_SECRET_KEY` | \-- | The provider's secret key. Required when `CASHPILOT_CAPTCHA_PROVIDER` is set |
| `CASHPILOT_WORKER_URL_POLICY` | `permissive` | Worker URL validation policy: `permissive` (LAN + Tailscale work out of the box) or `strict` (allowlist only) |
| `CASHPILOT_WORKER_ALLOWED_HOSTS` | \-- | Comma-separated CIDRs and `*.suffix` hostnames allowed in `strict` mode, e.g. `192.168.1.0/24,100.64.0.0/10,*.ts.net` |
| `CASHPILOT_WORKER_ALLOW_METADATA` | `false` | Escape hatch to permit cloud-metadata IPs as worker targets (leave `false`) |
| `CASHPILOT_NTFY_URL` | \-- | ntfy topic URL for out-of-band alerts, e.g. `https://ntfy.sh/my-topic` |
| `CASHPILOT_WEBHOOK_URL` | \-- | Generic endpoint receiving alert JSON (`title`, `message`, `kind`, `subject`) |
| `CASHPILOT_TELEGRAM_BOT_TOKEN` | \-- | Telegram bot token (needs `CASHPILOT_TELEGRAM_CHAT_ID` too) |
| `CASHPILOT_TELEGRAM_CHAT_ID` | \-- | Telegram chat to send alerts to |

### Alerts

Passive income is unattended, so an alert that only appears in an open browser tab is an alert nobody sees. Collector failures are **persisted** (they survive a restart and repopulate the notification bell) and, if any target above is configured, pushed out-of-band.

Notifications fire **only the first time** a particular failure appears: a collector that has been broken for a week does not notify every hour. When the service recovers, its stored alert is cleared, so a later failure counts as new and notifies again. With no target configured the feature is entirely inert.

### Worker

| Variable | Required | Default | Description |
| --- | :---: | --- | --- |
| `CASHPILOT_UI_URL` | Yes | \-- | URL of the CashPilot UI (e.g. `http://192.168.1.10:8080`). A remote worker uses the UI's published host port, so `:8088` if the UI host sets `CASHPILOT_UI_PORT=8088`. A worker beside the UI keeps `http://cashpilot-ui:8080`, the container port on the compose network. Plain `http://` works only to a private or Tailscale host; see [Plain HTTP only on your own network](<#plain-http-only-on-your-own-network>) |
| `CASHPILOT_API_KEY` | Yes | \-- | Must match the UI's API key |
| `CASHPILOT_WORKER_NAME` | No | *(hostname)* | Display name for this worker. Recommended on Docker workers: without it the name is the container hostname, so it changes on every recreate and the dashboard label churns -- see [Worker identity](<#worker-identity>) |
| `CASHPILOT_WORKER_URL` | No | *(auto-detected)* | URL the UI uses to reach this worker. Set explicitly for remote/cross-host workers -- auto-detection can report an unreachable address. The UI sends no command to a plain `http://` URL on a public host; see [Plain HTTP only on your own network](<#plain-http-only-on-your-own-network>) |
| `CASHPILOT_PORT` | No | `8081` | Port the worker **advertises** to the UI. It does *not* change the listen port, which is fixed by the image's `CMD`; see the [configuration reference](<https://geiserx.github.io/CashPilot/nl/configuration/index.md>) |
| `CASHPILOT_ALLOWED_VOLUME_ROOTS` | No | *(none)* | Colon-separated host directories this worker may bind-mount despite sitting under a blocked system root -- see [Volume mounts](<#volume-mounts>) |
| `CASHPILOT_PIDS_LIMIT` | No | `512` | Max processes a deployed service container may create. Raise only if a service legitimately needs more. An unparseable or non-positive value falls back to the default |
| `CASHPILOT_WORKER_NETWORK` | No | *(detected)* | `residential` or `hosting`. Overrides the hardware-based guess -- see [Egress IP and per-IP limits](<#egress-ip-and-per-ip-limits>) |
| `CASHPILOT_EGRESS_DETECT` | No | on | Set to `off` to stop this worker looking up its own public IP. The fleet then reports its exit as undetermined |
| `CASHPILOT_EGRESS_IP` | No | \-- | State this worker's public IP directly instead of looking it up. Must be a public address; a LAN or tailnet address is rejected |
| `CASHPILOT_EGRESS_IP_URL` | No | \-- | Use your own IP-echo endpoint (must return a bare IP) instead of the public ones |

The worker also reads `CASHPILOT_DRIFT_WARNINGS`, `CASHPILOT_ISOLATION`, `CASHPILOT_FENCE_EXITS`, `CASHPILOT_CONTAINER_NETWORK`, `CASHPILOT_CONTAINER_DNS`, `CASHPILOT_CONTAINER_RUNTIME` and `CASHPILOT_CONTAINER_RUNTIME_OVERRIDES`. They are described in the [configuration reference](<https://geiserx.github.io/CashPilot/nl/configuration/index.md>).

### Egress IP and per-IP limits

Providers count devices per **IP address**, not per machine. Honeygain treats a second active device on a network as "network overused", and EarnApp documents that extra devices behind one IP share a single daily cap. Two workers in one house are two machines on your dashboard and **one customer** to the provider, so the second one usually earns nothing.

Each worker therefore reports the public address it leaves the internet through, and the UI can group the fleet by that address (`/api/fleet/egress-groups`) rather than by host. Deploying a service to a machine that shares an address with one already running it is called out before the deploy, by name.

Three things worth knowing about how this behaves:

- **A worker whose exit could not be determined is reported as undetermined, never as sharing.** No warning is produced for it at all. That is deliberate: a wrong conflict warning is worse than none.
- **Private addresses are ignored.** A LAN or tailnet (`100.64/10`) address means detection failed, not that the machine exits there.
- **A service with no documented per-IP limit is treated as unknown, not unlimited.** You are told to check the provider's terms rather than reassured.

Detection is local where it can be. The "is this a hosted machine?" hint comes from the machine's own hardware identifiers, so nothing is sent anywhere and it works offline; a plain hypervisor such as QEMU or VMware is **not** treated as hosting, because a VM on a home server is a residential connection.

The public-IP lookup is the one outbound call CashPilot makes purely to learn about your setup. It is a single request per hour to a public IP-echo service. Turn it off with `CASHPILOT_EGRESS_DETECT=off`, point it at your own endpoint with `CASHPILOT_EGRESS_IP_URL`, or skip it entirely by stating the address with `CASHPILOT_EGRESS_IP`.

With detection off, the fleet simply reports that worker's exit as undetermined and raises no conflict warnings for it.

Known limitation: grouping matches on the exact address, so on a **native-IPv6** connection each machine has its own global address and no conflict is detected. The check is therefore best-effort: it can miss a conflict, but it will not invent one.

### Volume mounts

A worker refuses to bind-mount host paths under system roots such as `/`, `/etc`, `/var/run` (which covers the Docker socket), `/var/lib/docker` and `/mnt`, so a fleet-key holder cannot mount the host filesystem or a co-located app's secrets into a service container.

A few services legitimately need a directory under one of those roots -- most notably **Storj**, which wants a large data directory, and on Unraid the only such path is under `/mnt/user/...`. Opt in exactly that directory:

```
environment:
  - CASHPILOT_ALLOWED_VOLUME_ROOTS=/mnt/user/storj
```

Multiple paths are colon-separated. Behind the [Docker socket proxy](<https://geiserx.github.io/CashPilot/nl/security-defaults/index.md#docker-socket-proxy>), the proxy has to allow the path too: list it in `CASHPILOT_PROXY_BIND_MOUNTS` instead, which counts for both. That list is exact: it opens each path it names, never a folder under one. An entry must clear two gates:

- **Never a system path.** Anything resolving under `/etc`, `/root`, `/proc`, `/sys`, `/dev`, `/boot`, `/usr`, `/bin`, `/sbin`, `/lib`, `/run` or `/var` is refused **at any depth**, so `/run/docker.sock`, `/var/lib/docker/...` and `/etc/shadow` cannot be opted in.
- **Specific enough to be a service directory.** It must sit at least two components below the root it belongs to, so `/mnt/user/storj` is accepted while `/mnt` and `/mnt/user` (the entire Unraid array) are not.

Relative paths are refused, and refusals are logged with the reason.

> [!WARNING]
>
> **Residual risk: allowlist only directories you trust**
>
> The worker resolves paths in its **own** mount namespace and cannot see the host filesystem, so a symlink created *inside* an allowlisted directory by the service that owns it resolves differently here than in the Docker daemon. Only allowlist a directory whose contents you are willing to treat as trusted, and prefer a dedicated path (`/mnt/user/storj`) over a shared one.

### Deployed-container hardening

Service containers are third-party and closed-source, so the worker deploys them with the minimum kernel surface: **all capabilities dropped**, then only the ones that service's own catalog entry declares added back. They also get `no-new-privileges`, a PID limit, and are **never** privileged: `privileged` is refused by spec validation and is not an accepted argument in the deploy path at all.

If you add a service that genuinely needs a capability, declare it in that service's YAML (`docker.cap_add`). The check is **per service**: a slug may only request the capabilities its own catalog entry declares, so adding one to one service grants nothing to the others. Today that is Mysterium's `NET_ADMIN`, `SETUID` and `SETGID` (its node configures the VPN interface through `sudo`) and Bitping's `NET_RAW`.

### Worker identity

The UI keys each worker's row -- and its per-worker fleet key -- on a `client_id`, persisted at `/data/.worker_id`. That file is written on first run and reused forever, so a worker keeps its row across restarts and upgrades.

Inside a container `socket.gethostname()` is the first 12 hex characters of the container ID, regenerated every time the container is recreated -- which is exactly what an image bump does. A name of that shape is therefore never adopted as an identity: a worker that finds no `/data/.worker_id` generates and persists a random one instead.

Setting **`CASHPILOT_WORKER_NAME`** keeps the dashboard label stable across recreates (otherwise it follows the container hostname and churns on every upgrade), and gives a worker enrolled before `/data/.worker_id` existed a durable identity to migrate on.

> [!WARNING]
>
> **Symptom: heartbeats 401 after an upgrade**
>
> If a worker's identity changes, it keeps its valid per-worker key but presents it under an unknown `client_id`, and the UI correctly refuses it. Every heartbeat then returns `401 Unauthorized` and the worker drops out of the fleet -- while its service containers keep running and earning, so nothing else looks wrong.
>
> To reclaim the existing row: stop the worker, write the `client_id` the UI lists for it into `/data/.worker_id` (owned/readable by the container user), start it again, and set `CASHPILOT_WORKER_NAME` so it cannot recur. The worker logs this remediation itself after three consecutive rejections.

### Worker URL Validation

The UI validates every worker URL before contacting it (the URL is fetched with the fleet bearer token attached, so an unchecked URL is an SSRF risk). Cloud-metadata addresses and loopback/link-local ranges are **always blocked**, and resolved hostnames are re-checked against the same rules to guard against DNS rebinding.

- **`permissive`** (default): LAN (RFC1918) and Tailscale (CGNAT `100.64.0.0/10`) workers keep working with no configuration. Only the always-blocked ranges are rejected. A worker on a public address must use `https://`.
- **`strict`**: workers must match `CASHPILOT_WORKER_ALLOWED_HOSTS`. Entries are either CIDRs (`192.168.1.0/24`) or hostname suffixes (`*.ts.net`).

> [!IMPORTANT]
>
> **Tailscale in strict mode**
>
> If you use Tailscale and enable `strict` mode, include `100.64.0.0/10` in `CASHPILOT_WORKER_ALLOWED_HOSTS` (and/or `*.ts.net` for MagicDNS names). Without it, Tailscale workers are rejected.

Both policies refuse plain `http://` to a public host, even one on the allowlist ([Plain HTTP only on your own network](<#plain-http-only-on-your-own-network>)).
