This commit is contained in:
Mateusz Gruszczyński committed 2026-11-14 09:57:21 +01:00
1 parent ad0ff60632
commit 6b59434ffa
60 files changed
+7418 -732

No files matched your search

+37 -3
View File
@@ -4,7 +4,7 @@ The optional `rustproxy-docker-agent` runs **on a Docker host**, not on the Rust
## Requirements and security
- Linux amd64/x86_64 with **systemd and Docker Engine** (including a usable `/var/run/docker.sock`). No FreeBSD `pkg` is built for this agent.
- Linux amd64/x86_64 with **systemd and Docker Engine or Podman** (a usable `/var/run/docker.sock` or Podman API socket, see [Podman](#podman)). No FreeBSD `pkg` is built for this agent.
- Restrict inbound port `9876` to the RustProxy server through a firewall. The example binds `0.0.0.0:9876`; this is reachable from other machines when the firewall permits it.
- Access to `docker.sock` grants substantial **host-level privilege**, regardless of the agent's read-only HTTP API. The service uses a dedicated unprivileged identity granted access to the `docker` group.
- Self-signed ECDSA P-256 HTTPS is enabled by default; the certificate and private key persist under `/var/lib/rustproxy-docker-agent/` and are **not** regenerated on upgrades/restarts. The key is `0600`.
@@ -44,7 +44,16 @@ sudo systemctl status rustproxy-docker-agent
sudo journalctl -u rustproxy-docker-agent -n 100 --no-pager
```
Configure **RustProxy → Settings → Docker agents** with the host's `https://host:9876` URL, the full Bearer token, and the printed certificate SHA-256 fingerprint. The RustProxy server pins the certificate when a fingerprint is configured; a replaced certificate requires updating the fingerprint in the panel.
The quickest way to connect RustProxy is the **provisioning code**:
```bash
sudo rustproxy-docker-agent provision-code
# RPDA1-eyJ2IjoxLCJuYW1lIjoiZG9ja2VyMSIsImVuZHBvaW50Ijoi...
```
Paste it into **RustProxy → Settings → Docker agents → Paste provisioning code**. The panel fills in the agent name and ID, the `https://IP:port` endpoint, the Bearer token and the pinned certificate SHA-256 fingerprint. By default the code is **one-time**: `RPDA1-` + base64url JSON with the endpoint, the certificate fingerprint and an enrollment secret valid for 15 minutes (`--ttl`). RustProxy redeems it at `POST /v1/enroll` over the pinned HTTPS connection and receives the permanent token; the secret is stored hashed in `enrollment.json` next to the TLS key and removed on use. `--static` prints the older reusable code, which **contains the secret token**. The endpoint host is `RUSTPROXY_DOCKER_ADVERTISE_IP`, a concrete listen address or the routed IP; override it with `--endpoint-host docker1.example.net` (or `RUSTPROXY_DOCKER_ENDPOINT_HOST`). `info --show-token` also prints the code.
Alternatively configure **RustProxy → Settings → Docker agents** manually with the host's `https://host:9876` URL, the full Bearer token, and the printed certificate SHA-256 fingerprint. The RustProxy server pins the certificate when a fingerprint is configured; a replaced certificate requires updating the fingerprint in the panel.
## CLI commands
@@ -55,6 +64,8 @@ Configure **RustProxy → Settings → Docker agents** with the host's `https://
| `sudo rustproxy-docker-agent info` | Show listening endpoint, hostname, Docker socket, token status/length, TLS certificate paths, SHA-256, issuer, subject, SAN, serial, algorithms and validity |
| `sudo rustproxy-docker-agent info --show-token` | Explicitly reveal the full Bearer token in addition to metadata |
| `sudo rustproxy-docker-agent show-token` | Print **only** the full secret token (protect stdout) |
| `sudo rustproxy-docker-agent provision-code [--ttl 15m] [--endpoint-host HOST]` | Print a one-time `RPDA1-…` code (endpoint, certificate fingerprint, single-use enrollment secret) for the RustProxy panel; HTTPS only |
| `sudo rustproxy-docker-agent provision-code --static` | Print a reusable code that contains the Bearer token (**sensitive**) |
| `sudo rustproxy-docker-agent rotate-token` | Create a new token without replacing the certificate; **restart the service and update RustProxy** before continuing |
| `sudo rustproxy-docker-agent cert-init` | Create a missing certificate/key and print SHA-256; never overwrites existing valid certificate/key |
| `sudo rustproxy-docker-agent print-fingerprint` | Print current SHA-256 certificate fingerprint |
@@ -93,12 +104,35 @@ Both installation types use the **same** config and certificate paths, but diffe
Upgrades do not reset credentials or private state. The environment file is installed with `config|noreplace`; local edits remain in place according to package-manager conffile behavior. Removal does not delete `/etc/rustproxy/docker-agent.env` or `/var/lib/rustproxy-docker-agent` (back these up separately).
## Container labels and state
With **Publish from container labels** enabled in RustProxy, containers with `rustproxy.enable=true` are published automatically (see `docs/DOCKER_DISCOVERY.md`). The agent forwards only `rustproxy.*` labels. For every published container it also reports state, health check, restart count, CPU and memory (`GET /containers/{id}/json` and `/stats?stream=false&one-shot=true`, at most 64 containers per poll). Labels and container state are sent only to RustProxy 0.37.0+ (`?system=1`); `RUSTPROXY_DOCKER_SYSTEM_INFO=false` also disables container statistics.
## Podman
The agent speaks the Docker Engine API, which Podman also serves on its API socket. With `RUSTPROXY_DOCKER_SOCKET=auto` (the default) the agent uses `/var/run/docker.sock` when present, then `/run/podman/podman.sock`, then `$XDG_RUNTIME_DIR/podman/podman.sock` (rootless). Set an explicit path or `unix://` URL to choose one.
Rootful Podman:
```bash
sudo systemctl enable --now podman.socket
# Give the service group access to the socket (the installer creates a 'docker' group when Podman is found):
sudo systemctl edit podman.socket # [Socket] SocketGroup=docker SocketMode=0660
sudo systemctl restart podman.socket rustproxy-docker-agent
```
Containers started by `podman-compose` are grouped by their `com.docker.compose.*` or `io.podman.compose.*` labels exactly like Docker Compose services. Ports published by a Podman **pod** belong to the pod's infra container and are reported under that container name. The agent details in RustProxy show `podman` as the runtime.
## Host diagnostics
RustProxy 0.37.0 and newer request `GET /v1/inventory?system=1`; the agent then adds a `system` object with the OS name, kernel, architecture, uptime, load average, CPU count and usage, memory/swap, disk usage of the container data directory, host network totals and rates (container and virtual interfaces excluded), the runtime (`docker`/`podman`) with its version and running/total container and image counts. Older RustProxy versions never receive the block. Values the agent cannot read are omitted. Set `RUSTPROXY_DOCKER_SYSTEM_INFO=false` (or `--no-system-info`) to stop reporting it.
## API and troubleshooting
The API is `GET /v1/inventory` with `Authorization: Bearer <token>`; `GET /healthz` has no inventory and requires no token. Both use HTTPS by default. Plain HTTP is possible with `RUSTPROXY_DOCKER_AGENT_TLS=false` but exposes credentials in transit; use it only in a secured network and never across the public Internet.
- `no valid token`: execute `sudo rustproxy-docker-agent init`; check env file permissions and `EnvironmentFile`.
- `Docker socket unavailable`: install/start Docker Engine, check `/var/run/docker.sock`, the `docker` group and membership of `rustproxy-docker-agent`.
- `container socket unavailable`: install/start Docker Engine (or `podman.socket`), check `/var/run/docker.sock` / `/run/podman/podman.sock`, the `docker` group and membership of `rustproxy-docker-agent`.
- `TLS certificate/key`: inspect ownership of `/var/lib/rustproxy-docker-agent/`, mode `0600` on the private key, and both certificate/key paths. Refuse partially missing pairs rather than overwriting them.
- `x509` or fingerprint mismatch in RustProxy: compare `sudo rustproxy-docker-agent print-fingerprint` with the pin configured in Settings.
- Cannot reach port `9876`: check `RUSTPROXY_DOCKER_AGENT_LISTEN`, listening socket, firewall, and that HTTPS is used.