Files
Hello/server/deploy/Caddyfile
T
Thomas KarnerandClaude Opus 5 6907d9a014 Add a front door, a user guide in two languages, and an honest list of what is broken
Four documents and two fixes to the deploy directory that the documents
exposed while being written.

The repo had no root README. Cloning it landed you on a 40 KB spec and a 24 KB
plan with nothing to orient you, which mattered more once main stopped being
an empty branch. The new one links rather than duplicates, and its status table
says plainly what has never run on hardware and that there are no backups.

docs/README.USER.md and its German twin are written for someone who will use
this, not build it: what radar buys over a PIR sensor, why there is no sign-up
page, what "pre-trigger" means, what to do when the six-digit code is refused.
Every POORBIRD_* setting is described in plain language, including the two that
cost an hour each the first time they bite. The German version is a
translation, not a mechanical flip of the English.

docs/OPEN-TOPICS.AI.md is the list nobody writes: unfixed security issues,
traps, and test debt, each labelled ACCEPTED, OPEN or TRAP, because the
difference between "known trade-off" and "not done yet" is the only thing that
makes such a list usable. It ends with a section of things that are NOT
problems -- the SHA-256/Argon2id split, the frozen 0001 migration, the finite
pool_timeout -- so they stop being rediscovered and "fixed".

Two real defects surfaced while documenting the install:

Nothing served the WebUI in production. The Caddyfile's human-facing block
only reverse-proxied to FastAPI, and FastAPI mounts no static files, so a
by-the-book install produced a working API and no gallery. It now has a
file_server with a try_files fallback, because the router does client-side
routing and without it only the entry page survives a reload.

INSTALL.md never created an account. With no sign-up endpoint, following it
end to end left you at a login form with no credentials that work -- the exact
wall hit on the dev machine today, and worse on a headless host. It also never
built or copied the UI, so a git pull on the server silently kept the old
bundle; that is now its own step, with --delete spelled out because Vite emits
content-hashed filenames.

Verified: caddy validate via the official caddy:2 image reports "Valid
configuration" (with the cloudflare-DNS block stripped, since that plugin is
not in the stock image and the block is unchanged); npm run build is clean at
192 modules; all 31 relative links across every .md resolve; the committed
line endings are LF, so caddy fmt's complaint was my working tree only.

Not verified: none of the install has run on a real host. The doc says so.

One claim was wrong before it shipped: both guides said signing out ends every
session everywhere. logout calls revoke_session for the current token only --
revoke_all_for_user exists but is not called there -- so it ends that browser's
session alone, and `user passwd` is what clears them all. Corrected in both
languages.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-21 23:01:20 +02:00

97 lines
3.0 KiB
Caddyfile

# poorBird reverse proxy. Install to /etc/caddy/Caddyfile.
#
# Ports, so nothing collides:
# 127.0.0.1:8090 uvicorn (POORBIRD_API_PORT) -- never exposed
# :8080 plain HTTP for the camera (SPEC C2, firmware/API.md)
# :443 TLS for humans
#
# TLS: Caddy gets a real Let's Encrypt certificate for a LAN-only hostname via
# DNS-01, so there is no port forwarding and no browser warning. That needs a
# Caddy build with your DNS provider's plugin:
#
# caddy add-package github.com/caddy-dns/cloudflare
#
# For a first test on any Linux box you can skip the whole human-facing block
# and just use the :8080 one.
(protected_files) {
# Auth-checked image serving (SPEC 3.3).
#
# An unguessable URL is not access control. The app authorizes the
# request, then replies with an empty body and
# X-Accel-Redirect: /images/2026/09/08/<uuid>.jpg
# and Caddy serves the bytes from disk. The browser never receives a
# directly fetchable URL.
#
# The root below is the PARENT of POORBIRD_IMAGE_ROOT and
# POORBIRD_THUMB_ROOT in /etc/poorbird/poorbird.env. One value, two
# readers -- keep them in step.
@accel header X-Accel-Redirect *
handle_response @accel {
rewrite * {rp.header.X-Accel-Redirect}
file_server {
root /srv/poorbird
}
}
}
# --- humans -----------------------------------------------------------------
poorbird.example.internal {
tls {
dns cloudflare {env.CLOUDFLARE_API_TOKEN}
}
encode zstd gzip
# The API, and with it the auth-checked image handoff.
handle /api/* {
reverse_proxy 127.0.0.1:8090 {
header_up X-Real-IP {remote_host}
import protected_files
}
}
# The WebUI: built on the dev machine with `npm run build` and copied here
# as static files. Nothing in web/ runs on the server (SPEC 6), so this is
# a file_server and not a second application.
handle {
root * /srv/poorbird/web
# The router does client-side routing, so a reload on /devices or a
# pasted deep link arrives as a path with no file behind it. Without
# this fallback those are 404s and only the entry page ever works.
try_files {path} /index.html
file_server
}
}
# --- the camera --------------------------------------------------------------
# Plain HTTP on the LAN, deliberately (SPEC C2): TLS on the ESP32 means a CA
# baked into firmware, and a mounted camera that silently stops uploading when
# the chain rotates.
:8080 {
handle /api/v1/* {
request_body {
# A burst frame at UXGA can be a few hundred KB; an OTA image is
# ~1-2 MB. The default limit is too small for both.
max_size 12MB
}
reverse_proxy 127.0.0.1:8090 {
# Required, not cosmetic. Rate limiting keys enrollment on the
# caller's address, and without this every camera arrives as
# 127.0.0.1 and they all share one bucket - one noisy device
# would lock the rest out. The app trusts this header only
# because uvicorn binds loopback and nothing else can reach it.
header_up X-Real-IP {remote_host}
}
}
handle /healthz {
reverse_proxy 127.0.0.1:8090
}
handle {
respond 404
}
}