diff --git a/README.md b/README.md index 20940f8..263776b 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Everything runs on your machine; nothing is sent anywhere. ### Docker Compose (recommended) One-time setup, as the user who should own the books (uid 1000 by default). -Create the data folder, then put a login password in `.env`: +Create the data folder, then put a login password in `.env` (optional, see below): ```bash mkdir -p data @@ -40,7 +40,8 @@ docker compose up -d --build ``` Open and log in as `cashbook` with the password from -`.env`. Compose refuses to start if `CASHBOOK_PASSWORD` isn't set. Stop it with `docker compose down`, and check it with +`.env`. With no `CASHBOOK_PASSWORD` set, there's no login: anyone who can reach the +port can see and change your books, so only do that on a network you trust. Stop it with `docker compose down`, and check it with `docker compose ps` (it reports `healthy`) or `docker compose logs`. **What the compose file sets up** @@ -48,7 +49,7 @@ Open and log in as `cashbook` with the password from - **Data:** `./data` is mounted at `/data` and holds the cashbooks and `statements/` (uploads go there). Back up this folder. - **Login:** HTTP Basic auth, with the password from the `CASHBOOK_PASSWORD` - environment variable. + environment variable. Leave it unset to turn the login off. - **Network:** published on `127.0.0.1:8765` only. - **Lockdown:** - read-only container filesystem, with scratch space only in `/tmp` (tmpfs); @@ -62,17 +63,23 @@ Open and log in as `cashbook` with the password from | Variable | Default | Purpose | |---|---|---| -| `CASHBOOK_PASSWORD` | *(required)* | login password | +| `CASHBOOK_PASSWORD` | *(none)* | login password; unset means no login | | `CASHBOOK_USER` | `1000:1000` | uid:gid to run as; it should own `data/`. Use `0:0` with rootless Docker, which maps container root to you. | | `CASHBOOK_USERNAME` | `cashbook` | login name | | `CASHBOOK_BIND` | `127.0.0.1` | host address to publish on | | `CASHBOOK_PORT` | `8765` | host port | +| `CASHBOOK_ALLOWED_HOSTS` | | extra host names you open the app by, comma-separated; see below | **Reaching it from other machines:** keep it on `127.0.0.1` and put a reverse proxy with HTTPS in front (Caddy, nginx, Traefik). Basic auth sends the password with every -request, so don't expose it over plain HTTP. The proxy must pass the original `Host` -header through; uploads and changes are refused when the page's origin doesn't match -it. For example, with Caddy: +request, so don't expose it over plain HTTP. + +To block other websites from making changes through your login, the app refuses +changes whose page address doesn't match the server's host name. It checks the +`Host` and `X-Forwarded-Host` headers. Caddy passes the original host through. With +nginx, add `proxy_set_header Host $host;`. Otherwise, list the name you use in +`CASHBOOK_ALLOWED_HOSTS`. A refused request shows up in `docker compose logs` with +the reason. A Caddy example: ``` cashbook.example.com { diff --git a/compose.yaml b/compose.yaml index 3eef64f..7bb454f 100644 --- a/compose.yaml +++ b/compose.yaml @@ -15,10 +15,13 @@ services: ports: - "${CASHBOOK_BIND:-127.0.0.1}:${CASHBOOK_PORT:-8765}:8765" - # Browser login (HTTP Basic). Set CASHBOOK_PASSWORD in .env; compose won't start without it. + # Browser login (HTTP Basic): set CASHBOOK_PASSWORD in .env. Leave it unset to turn + # the login off; then anyone who can reach the port can see and change your books. environment: CASHBOOK_USERNAME: "${CASHBOOK_USERNAME:-cashbook}" - CASHBOOK_PASSWORD: "${CASHBOOK_PASSWORD:?set CASHBOOK_PASSWORD in .env}" + CASHBOOK_PASSWORD: "${CASHBOOK_PASSWORD:-}" + # other host names you reach it by, if the proxy doesn't pass Host through + CASHBOOK_ALLOWED_HOSTS: "${CASHBOOK_ALLOWED_HOSTS:-}" volumes: # cashbooks and statements/ (uploads go there too) diff --git a/src/static/index.html b/src/static/index.html index 4e49580..e9c8c04 100644 --- a/src/static/index.html +++ b/src/static/index.html @@ -4,6 +4,7 @@ Cashbook +