From 9bccaaf85a75e8981b04d205b90c2755d418527a Mon Sep 17 00:00:00 2001 From: clawbot <35+clawbot@noreply.example.org> Date: Wed, 11 Nov 2026 22:40:59 +0100 Subject: [PATCH] README Getting Started ends with a signed image request (closes #357) Getting Started now runs script/bootstrap --cgo before make build, says that logging in at http://localhost:8080/ needs debug, and ends with a signed /v1/image/ request for an image on any public HTTPS server. Its curl exits non-zero when pixa refuses the request. Model: opus-5-5 --- README.md | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9522af0..91c1277 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,10 @@ In this document, the upstream host is the server that holds an original image. ## Getting Started ```bash -# clone and build +# clone, install what compiling needs, and build git clone https://git.eeqj.de/sneak/pixa.git cd pixa +script/bootstrap --cgo make build # make a config file from the example and put a real signing key in it @@ -26,18 +27,30 @@ openssl rand -base64 32 # prints a new signing key $EDITOR config.yml # replace the signing_key placeholder with it ./bin/pixad --config config.yml -# or build and run the Docker image +# or build and run the Docker image with that signing key make docker -docker run -p 8080:8080 -e PIXA_SIGNING_KEY="$(openssl rand -base64 32)" pixa:latest +docker run -p 8080:8080 -e PIXA_SIGNING_KEY='the new signing key' pixa:latest ``` -`make build` compiles pixa on your machine into `bin/pixad`. `pixad` is the -server program. Compiling needs the libraries `script/bootstrap --cgo` installs -(see Deployment). +`script/bootstrap --cgo` installs Go, a C compiler and the image libraries pixa +needs (see Deployment). `make build` then compiles pixa on your machine into +`bin/pixad`. `pixad` is the server program. The signing key is pixa's one required secret. It must be 32 characters or longer. The placeholder in the example file is refused at startup. +A container takes its settings from environment variables (see Configuration). +Only `PIXA_SIGNING_KEY` is required. Without it, the container exits at startup +and names the variable. Every other setting has a built-in default. A config +file mounted at `/etc/pixa/config.yml` is read when present. An environment +variable wins over the same setting in the file. + +pixa's login page is at `http://localhost:8080/`. Logging in there works only +with `debug: true` in `config.yml`, or `-e PIXA_DEBUG=true` for the container. +Otherwise pixa refuses the login with 403, because the page was opened over +plain HTTP. Use `debug` only on your own machine. A pixa that others use serves +its pages over HTTPS through a reverse proxy (see Deployment). + Once pixa runs, it serves images through URLs of this form: ``` @@ -60,11 +73,25 @@ The example config allowlists no host. Every image on an allowlisted host is served to anyone, without a signature, at any size and in any format. So allowlist only hosts you control, where nobody else can put images. -A container takes its settings from environment variables (see Configuration). -Only `PIXA_SIGNING_KEY` is required. Without it, the container exits at startup -and names the variable. Every other setting has a built-in default. A config -file mounted at `/etc/pixa/config.yml` is read when present. An environment -variable wins over the same setting in the file. +To see pixa serve an image, sign a URL for an image on any public HTTPS server. +Run this in a second terminal while pixa runs, with your own signing key and +image: + +```bash +key='the new signing key' +image_host=cdn.example.com # a public HTTPS server +image_path=/photos/cat.jpg # an image on it +exp=$(($(date +%s) + 3600)) # the URL expires in one hour +sig=$(printf '%s' "$image_host:$image_path::400:300:webp:$exp:85:cover" | + openssl dgst -sha256 -hmac "$key" -binary | base64 | tr '+/' '-_') +curl --fail-with-body -o cat.webp \ + "http://localhost:8080/v1/image/$image_host$image_path/400x300.webp?sig=$sig&exp=$exp" +``` + +`cat.webp` is then the image at 400x300. If pixa refuses the request, curl +reports an error and `cat.webp` holds pixa's error message instead. The image +path must not hold a `%`, a `:` or a query. Signed URLs explains how to sign +those. ## Deployment