Run it on a server
One machine per systemd instance (or per container), one system user per machine, one port per machine. The code is shared and read-only. TLS ends at a terminator in front.
systemd
As root, with the signed release in /opt/zeq:
install -d -m 755 /opt/zeq && cp -r zeq.py manifest.json plugins spectrum /opt/zeq/
python3 /opt/zeq/zeq.py > /opt/zeq/proved.txt # proved once as root: the boot record beside the file is the one production trusts
useradd --system --home-dir /srv/zeq/ana --shell /usr/sbin/nologin zeq-ana
install -d -o zeq-ana -m 700 /srv/zeq/ana
install -d -m 711 /etc/zeq
install -o zeq-ana -g zeq-ana -m 600 /dev/null /etc/zeq/ana.pin # then write the PIN into it
printf 'ZEQ_ISSUER_ZID=ZEQ7...\nZEQ_PORT=8801\nZEQ_TRUSTED_PROXIES=127.0.0.1\nZEQ_PUBLIC_HOST=example.org\n' > /etc/zeq/ana.env
cp deploy/zeq@.service /etc/systemd/system/ && systemctl daemon-reload
systemctl enable --now zeq@ana
- The first start. It creates the machine, sealed under the PIN in
/srv/zeq/ana. Every later start unlocks it. - The PIN. The machine reads it from
/etc/zeq/ana.pin: owned by the machine's user, mode 600, never in its environment. A PIN file anyone else can read is refused. - Listening. It listens on
127.0.0.1:ZEQ_PORT. - More machines. Each further machine is another instance, with its own user, folder, PIN, env and port.
The terminator (nginx)
server {
listen 443 ssl;
server_name example.org;
ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
client_max_body_size 2m;
location / {
proxy_pass http://127.0.0.1:8801;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off; # /pulse streams one event per Zeqond
proxy_read_timeout 1h;
}
}
Two settings are required behind a terminator:
- **
ZEQ_TRUSTED_PROXIES** lists the terminator's address, so each client keeps its own rate limit. - **
ZEQ_PUBLIC_HOST** names the site. A machine on loopback answers any otherHostwith421.
Working with it
cat /srv/zeq/ana/machine.owner.key # the owner's key
cd /srv/zeq/ana && sudo -u zeq-ana -H env ZEQ_PIN_FILE=/etc/zeq/ana.pin \
python3 /opt/zeq/zeq.py --key issue laptop read 30 # a key for one holder
journalctl -u zeq@ana
Health, metrics, logs
| Route | Access | What it gives |
|---|---|---|
GET /health | public | {"status": "ok", "version": "…", "api": 1}; use GET (the machine does not answer HEAD) |
GET /metrics | read key | Prometheus text: requests by route and status, uptime, log rows, live keys |
ZEQ_ACCESS_LOG=json writes one JSON line per request to stderr. A key is named by its holder or its first characters, never in full.
Backups and upgrades
- Backups.
machine.zeqand the PIN, kept apart, are the machine. The whole folder is its history: copy/srv/zeq/anawith the service stopped, and keep the PIN elsewhere. - Upgrades. Stop the service, replace the files with the newer signed release, prove it, carry each machine in its own folder (
zeq.py --carry), then start.
Settings
| Setting | What it does |
|---|---|
ZEQ_ISSUER_ZID | the publisher's ZID, pinned |
ZEQ_PORT, ZEQ_BIND | the port, and the address plain HTTP listens on (127.0.0.1 by default) |
ZEQ_PUBLIC_HOST, ZEQ_TRUSTED_PROXIES | the site's name, and the terminators whose X-Forwarded-For is read |
ZEQ_ORIGINS | browser origins allowed to call the API |
ZEQ_RATE_LIMIT | requests per 60 s per address (default 120) |
ZEQ_WEBHOOK | an address each sealed answer is posted to, signed |
ZEQ_NAME, ZEQ_ANCHOR | a name stated at birth, and the foundation ZID the machine anchors to at birth |
ZEQ_MODULES | the modules to plug in (all by default) |
ZEQ_PRODUCTION | 1: refuse to boot unless every file is exactly the publisher's |