diigo binds the session cookie to the IP it was issued to, so a Cloudflare deployment can't use a cookie minted in the browser. Run diigo-cache and webapp in one workerd on bldbox instead. The flake bundles each worker with wrangler's dry run, so the modules match what `wrangler deploy` ships, and generates the workerd config from the bundles. workerd comes from nixpkgs' wrangler, the only packaged one. A smoke check serves the home page and mints a webapp instance, which covers the WEBAPP binding and Durable Object storage. The service is a system unit with DynamicUser, so the webapp state holding the cookie isn't readable by processes running as the user. It listens on loopback behind tailscale serve: HTTPS, which PasswordCredential needs, at the tailnet name only. Operator docs in doc/; unsettled points recorded as IBIS issues. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2.7 KiB
Day to day
Create a cache
As in the README, at https://bldbox.tail09e44.ts.net/ instead of localhost: mint, wire, save the ids, fill. Copy the cookie from a browser running on bldbox: diigo accepts it only from the IP it was issued to (see issue 1).
The public page is then https://bldbox.tail09e44.ts.net/public/<diigo username>?days=7, on the tailnet only.
Logs
journalctl -u diigo-cache.service -f -o cat |
jq -Rr 'fromjson? | "\(.timestamp / 1000 | todate) \(.level) \(.message | gsub("\\s*\\n\\s*"; " "))"'
fromjson? skips lines that aren't JSON: systemd's own ("Started …") and entries from before structuredLogging.
workerd runs with structuredLogging: each entry is one line of JSON, {timestamp, level, message}. message is the logged object as console.log prints it, not JSON: on Cloudflare, Workers Logs indexes the fields of a logged object, so the workers log objects rather than strings.
workerd logs the workers' console.* output: {event: "cache", kind, page, outcome} per page read, {event: "fill", state, …} per fill step, {event: "mint"}. Ids show only as fingerprints; the cookie never appears.
State
With DynamicUser=yes, systemd keeps the state in /var/lib/private/diigo-cache/ (/var/lib/diigo-cache is a symlink to it), mode 0700, owned by a uid that exists only while the service runs:
| Dir | Holds | Secret? |
|---|---|---|
cache/diigo-cache-DiigoCache/ |
private caches: every bookmark | yes |
cache/diigo-cache-PublicCache/ |
public caches and the username index | no |
webapp/webapp-WebAppDo/ |
webapp instances: the diigo cookie | yes, a credential |
Each Durable Object is one <id hash>.sqlite. Read one with the service stopped, or copy it first: sudo sqlite3 -readonly <file> .tables.
Backups
The private caches are refillable from diigo; the cookie can be re-minted. What's lost with the state is the binding from the ids people saved to these objects. Backups hold the cookie, so treat them as secret.
sudo systemctl stop diigo-cache.socket diigo-cache.service # the socket would restart it
sudo tar -C /var/lib/private -czf diigo-cache-$(date +%F).tgz diigo-cache
sudo systemctl start diigo-cache.socket
No backup is scheduled (see open issue 6).
The cookie expires
When fills log {event: "fill", state: "failed"} with a diigo auth error, mint a fresh webapp instance and wire a new cache. A wired cache refuses a different webapp id (setup in cache.ts) (see open issue 7).