Install behind Caddy instead of nginx and acme.sh
Security / Vulnerability check (push) Successful in 52s
Test / Lint and test (push) Successful in 2m0s

install.sh sets up a fresh Debian or Ubuntu host behind Caddy, installed
from Caddy's apt repository, which obtains and renews the certificate
itself. The site goes to /etc/caddy/uberbringer.caddy and the Caddyfile
imports it; an edited Caddyfile only gains the import line. The result is
validated as the caddy user, and both files are put back if Caddy rejects
it. Caddy's body limit follows webserver.body_limit, and a larger body
gets the daemon's 413 body_too_large JSON. A re-run upgrades the binary,
the unit and Caddy and restarts the service. The script does not migrate
hosts set up by the 0.1 script.

The Docker image stays a proxy-free microservice behind the operator's
own reverse proxy. The README credits the pre-refactor code, written
without AI, and design.md records the persistent job store and image
previews as deferred work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
57_WolveandClaude Opus 5.5 committed 2026-11-30 01:09:07 -06:00
1 parent 4562f0cebb
commit 92dcacb3b9
7 files changed
+353 -278

No files matched your search

+31 -10
View File
@@ -8,12 +8,12 @@ daemon is shaped as it is. README.md describes how to use it.
Scripts and services on the owner's network send short JSON jobs, and one
Epson receipt printer prints them. The daemon replaces the 0.1 one on the
same endpoint, `POST /api/v1/print` behind nginx, and 0.1 installs are
deployed. It is one static binary with no database, sized for receipt rates
on one printer.
same endpoint, `POST /api/v1/print` behind a TLS reverse proxy, and 0.1
installs are deployed. It is one static binary with no database, sized for
receipt rates on one printer.
```text
client ─HTTPS─▶ nginx ─▶ server ── validate ──▶ printqueue (memory, 1 worker)
client ─HTTPS─▶ Caddy ─▶ server ── validate ──▶ printqueue (memory, 1 worker)
│ │ receipt.Render: whole job
│ │ to bytes, images via safehttp
│ ▼
@@ -123,10 +123,19 @@ client ─HTTPS─▶ nginx ─▶ server ── validate ──▶ printqueue (
- TypeID (UUIDv7) job and request IDs instead of snowflakes. They sort by
time and need no node configuration.
- An Alpine Docker image.
- **Packaging.** The release tarballs are built for linux amd64, armv6, armv7
and arm64. `install.sh` sets up nginx (TLS, `X-Real-IP`), acme.sh and the
sandboxed unit from `packaging/`. The daemon binds 127.0.0.1 by default and
serves no TLS itself.
- **Packaging.** The daemon serves no TLS itself and binds 127.0.0.1 by
default; a reverse proxy in front terminates HTTPS and sets `X-Real-IP`.
- The release tarballs are built for linux amd64, armv6, armv7 and arm64.
`install.sh` sets up Caddy as that proxy (TLS with automatic
certificates, `X-Real-IP`) and the sandboxed unit from `packaging/`.
Caddy replaced nginx and acme.sh because it issues and renews
certificates itself, so the installer needs no webroot, cron job or
certificate paths.
- `install.sh` sets up a fresh host, and re-runs upgrade what it set up.
It does not migrate hosts set up by the 0.1 script (owner, 2026-11-30).
- The Docker image is a microservice with no proxy inside: it runs behind
the operator's own reverse proxy, whose address goes in
`webserver.trusted_proxies`.
## Planned: formatters
@@ -149,8 +158,20 @@ and the preview, is built. Decided so far (owner, 2026-11-29):
that printer arrives.
- **Several printers from one instance**, through routing or a pool. Until
then, run one instance per printer.
- **A durable queue.** It needs a way to tell which receipts printed before a
crash.
- **A persistent job store and print previews** (requested by the owner on
2026-11-30; to be planned in full in `docs/plans/` before any of it is
built):
- Jobs stored with GORM on SQLite, so queued jobs, statuses and history
survive a restart. Release builds use `CGO_ENABLED=0`, so the SQLite
driver must be pure Go (for example `github.com/glebarez/sqlite`), and the
systemd unit needs a `StateDirectory` because its file system is
read-only. The plan must also say how to tell which receipts printed
before a crash, so a restart never prints a receipt twice.
- A print preview as an image: a digital test print of a job that shows
what the paper would look like, without printing. Formatters phase 1 adds
a text preview (`POST /api/v1/preview`); this goes further, rendering
text, boxes, barcodes, QR codes and images to a picture.
- Previews of submitted jobs, read back from the store by job ID.
- **Printer alerts sent out to ntfy** (paper out, cover open). They have not
been requested. Printing incoming ntfy messages is part of the formatters
plan.