README Getting Started ends with a signed image request (closes #357) #363

Merged
clawbot merged 1 commits from issue-357-getting-started-image into next 2026-11-11 22:40:59 +01:00
+38 -11
View File
@@ -15,9 +15,10 @@ In this document, the upstream host is the server that holds an original image.
## Getting Started ## Getting Started
```bash ```bash
# clone and build # clone, install what compiling needs, and build
git clone https://git.eeqj.de/sneak/pixa.git git clone https://git.eeqj.de/sneak/pixa.git
cd pixa cd pixa
script/bootstrap --cgo
make build make build
# make a config file from the example and put a real signing key in it # 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 $EDITOR config.yml # replace the signing_key placeholder with it
./bin/pixad --config config.yml ./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 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 `script/bootstrap --cgo` installs Go, a C compiler and the image libraries pixa
server program. Compiling needs the libraries `script/bootstrap --cgo` installs needs (see Deployment). `make build` then compiles pixa on your machine into
(see Deployment). `bin/pixad`. `pixad` is the server program.
The signing key is pixa's one required secret. It must be 32 characters or 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. 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: 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 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. allowlist only hosts you control, where nobody else can put images.
A container takes its settings from environment variables (see Configuration). To see pixa serve an image, sign a URL for an image on any public HTTPS server.
Only `PIXA_SIGNING_KEY` is required. Without it, the container exits at startup Run this in a second terminal while pixa runs, with your own signing key and
and names the variable. Every other setting has a built-in default. A config image:
file mounted at `/etc/pixa/config.yml` is read when present. An environment
variable wins over the same setting in the file. ```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 ## Deployment