aien-edge
aien-dev/aien-edge
Brought by drakestapleton
GitHub aien-dev/aien-edge#4 (code only)
Apply it
git checkout -b patch-794d9dfc1411ae0f cdd1c7f9b69ae2dcce383750060677c485476696 curl -fsSL https://interplane.io/drakestapleton/aien-edge/patches/794d9dfc1411ae0f.patch | git am
Provenance
github-import 1
aien-dev/aien-edge
4
6d05d5a674b03f6744806defd689cdba144602a0
{"kind":"github-import","owner":"aien-dev","repo":"aien-edge","number":4,"url":"https://github.com/aien-dev/aien-edge/pull/4","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:40:34Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/README.md b/README.md index fdc4692..647ec0c 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,15 @@ Copyright (c) 2026 Drake Stapleton <aien@aienos.com> and AIEN Contributors. Auth A small native Rust edge server for the AIEN static sites (`www.aienos.com`, `www.drakestapleton.com`). It runs on a Raspberry Pi at the network edge so the NVIDIA DGX Spark never faces the internet. -- **Everything in memory.** Each site is read once at startup, precompressed with brotli (quality 11) and gzip, and hashed for ETags. Requests never touch the disk. -- **Automatic HTTPS.** Let's Encrypt certificates through `rustls-acme` (TLS-ALPN-01 on port 443; port 80 only redirects). TLS is `rustls`; nothing is hand-rolled. +- **Everything in memory.** Each site is read once at startup (and again on reload). Text-like files of 1 KiB or more are precompressed with brotli (quality 11) and gzip, and every file is hashed for ETags. Requests never touch the disk. +- **Automatic HTTPS.** Let's Encrypt certificates through `rustls-acme` (TLS-ALPN-01 on port 443; port 80 only redirects), HTTP/2 and HTTP/1.1. TLS is `rustls`; nothing is hand-rolled. Without a `[tls]` table in the config the server runs plain HTTP only and serves content on the HTTP port (local testing). - **Virtual hosts.** Canonical host per site, apex to `www` 301 redirects, HTTP to HTTPS redirects, 421 for unknown hosts. - **Small attack surface.** GET and HEAD only, traversal-safe path normalization against an in-memory map (no filesystem lookups per request), hidden files and source maps never loaded, header-read and TLS-handshake timeouts, a connection cap, and security headers (HSTS, nosniff, frame denial, referrer policy). -- **Zero-downtime deploys.** `SIGHUP` (`systemctl reload aien-edge`) reloads every site; if the new copy fails to load, the old one keeps serving. +- **Zero-downtime deploys.** `SIGHUP` (`systemctl reload aien-edge`) reloads every site's files; if the new copy fails to load, the old one keeps serving. The config file is read only at startup, so config changes need a restart. ## Measured -On the Spark (aarch64), serving both built sites from one process, HTTP/1.1 keep-alive, brotli, against a page that returns 200 (`/research`, 6036 bytes brotli). Three runs: +On the Spark (aarch64), serving both built sites from one process, HTTP/1.1 keep-alive, brotli, against a page that returns 200 (`/research`, 6036 bytes brotli). Three runs on commit 59df18c, recorded in the message of commit 843cc77. The built sites are not in this repo, so the run cannot be repeated from here alone: ``` $ ab -k -n 50000 -c 64 -H "Host: www.drakestapleton.com" -H "Accept-Encoding: br" http://127.0.0.1:18777/research @@ -48,9 +48,9 @@ sudo mkdir -p /srv/sites/releases sudo systemctl daemon-reload && sudo systemctl enable --now aien-edge ``` -Then publish each site from the Spark with `deploy/publish-site.sh <name> <checkout>`. Keep `production = false` (Let's Encrypt staging) until both hosts issue certificates, then switch to `true` and reload. +The server exits at startup if a site root is missing or has no `index.html`, and `Restart=always` retries every 2 seconds, so publish the sites soon after the first start. Publish each site from the Spark with `deploy/publish-site.sh <name> <checkout>`: it runs `npm ci` and `npm run build` in the checkout, uploads `dist/` to `/srv/sites/releases/` on the Pi (`EDGE_HOST`, default `edge@10.10.10.2`), repoints `/srv/sites/<name>` and reloads, keeping the last three releases. Keep `production = false` (Let's Encrypt staging) until the certificates issue, then switch to `true` and restart (a reload does not re-read the config). -Network: forward TCP 80 and 443 on the router to the Pi only, and point the DNS A records for both apex and `www` hosts at the public IP. The Pi reaches the Spark only for deploys, over the direct link. +Network: forward TCP 80 and 443 on the router to the Pi only, and point the DNS A records for both apex and `www` hosts at the public IP. The Spark reaches the Pi (over ssh and rsync, on the direct link) only to deploy; aien-edge itself never connects to the Spark. ## License