Raise the upload rate limit to 30/min, burst 20
Test and deploy / test (push) Successful in 1m54s
Test and deploy / deploy (push) Successful in 1m2s

Dropping several pictures onto a canvas page uploads them all at once,
which the old 5/min, burst 3 limit cut off after three. Uploading needs
a signed-in user and accounts are admin-created, so a far higher
ceiling is still safe against filling the volume.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-14 23:48:44 +01:00
co-authored by Claude Opus 5.5
parent 30e1fb31d8
commit 30918eefaa
6 changed files with 12 additions and 8 deletions
+1 -1
View File
@@ -62,7 +62,7 @@ Dockerized multi-service personal website self-hosted on a Raspberry Pi.
**Job tracker** (`jobs` service, `/jobs/`): the job application tracker, leads inbox, email pipeline and capture userscript now live in their own repo (`adamf/job-tracker` on Gitea) and run here as a published image, with their own Postgres database and role. It has no login: it asks the backend's `/auth/validate-admin` with the visitor's cookies. Nothing of it is left in `backend/`, `python/` or `vue/`; nginx redirects the old `/cv/jobs`, `/cv/leads` and userscript URLs to `/jobs/`. A push to that repo's `main` publishes the image and rolls this stack's `jobs` container onto it; pin `JOBS_IMAGE_TAG` in `.env` to hold a version. Its variables are in `env_registry.json` with `services: ["jobs"]`. **Job tracker** (`jobs` service, `/jobs/`): the job application tracker, leads inbox, email pipeline and capture userscript now live in their own repo (`adamf/job-tracker` on Gitea) and run here as a published image, with their own Postgres database and role. It has no login: it asks the backend's `/auth/validate-admin` with the visitor's cookies. Nothing of it is left in `backend/`, `python/` or `vue/`; nginx redirects the old `/cv/jobs`, `/cv/leads` and userscript URLs to `/jobs/`. A push to that repo's `main` publishes the image and rolls this stack's `jobs` container onto it; pin `JOBS_IMAGE_TAG` in `.env` to hold a version. Its variables are in `env_registry.json` with `services: ["jobs"]`.
**Nginx** (`nginx/`): Reverse proxy + SPA server. Config is templated (`nginx.conf.template`) and selected at runtime by `entrypoint.sh` based on `DEV_MODE` and certificate presence. Rate limiting on login (5/min), API (30/sec), uploads (5/min). Proxied routes are written once, in `nginx/nginx_routes.conf.template`, which both the production and dev configs include — add a new route there. Production-only pieces (TLS, static asset caching, the GraphQL rate-limit zone, security headers) stay in `nginx.conf.template`; a new rate-limit zone must be declared in both `http` blocks. **Nginx** (`nginx/`): Reverse proxy + SPA server. Config is templated (`nginx.conf.template`) and selected at runtime by `entrypoint.sh` based on `DEV_MODE` and certificate presence. Rate limiting on login (5/min), API (30/sec), uploads (30/min, burst 20). Proxied routes are written once, in `nginx/nginx_routes.conf.template`, which both the production and dev configs include — add a new route there. Production-only pieces (TLS, static asset caching, the GraphQL rate-limit zone, security headers) stay in `nginx.conf.template`; a new rate-limit zone must be declared in both `http` blocks.
## Backend Structure ## Backend Structure
+1 -1
View File
@@ -333,7 +333,7 @@ rate"*. Anything beyond the burst gets an immediate **503**.
| `login` | 5/min | 3 | `/api/auth/login` | Brute-force defence. A human mistyping gets 3 tries then one per 12s; a credential-stuffing script gets nothing useful. | | `login` | 5/min | 3 | `/api/auth/login` | Brute-force defence. A human mistyping gets 3 tries then one per 12s; a credential-stuffing script gets nothing useful. |
| `api` | 30/sec | 20 | `/api/`, `/py/` | Generous on purpose — one SPA page load fans out to several calls. An abuse ceiling, not a quota. | | `api` | 30/sec | 20 | `/api/`, `/py/` | Generous on purpose — one SPA page load fans out to several calls. An abuse ceiling, not a quota. |
| `graphql` | 10/sec | 10 | `/api/graphql` | Tighter than REST because one query can be arbitrarily expensive. **Production config only**; dev folds GraphQL into `api`. | | `graphql` | 10/sec | 10 | `/api/graphql` | Tighter than REST because one query can be arbitrarily expensive. **Production config only**; dev folds GraphQL into `api`. |
| `upload` | 5/min | 3 | `/api/messages/upload` | Uploads can be 50MB and hit disk; bounds how fast one IP fills the volume. | | `upload` | 30/min | 20 | `/api/messages/upload` | Uploads hit disk; bounds how fast one IP fills the volume. Generous because uploaders must be signed in (accounts are admin-created) and a batch of pictures dropped on a canvas page uploads at once. |
| `hotel_search` | 3/min | 2 | `/py/hotels/(search\|scan)` | Each request holds an upstream call for minutes and the Python side has one search slot — concurrency protection more than abuse protection. | | `hotel_search` | 3/min | 2 | `/py/hotels/(search\|scan)` | Each request holds an upstream call for minutes and the Python side has one search slot — concurrency protection more than abuse protection. |
The WebSocket endpoint is deliberately unlimited: a socket is one long-lived The WebSocket endpoint is deliberately unlimited: a socket is one long-lived
+1 -1
View File
@@ -147,7 +147,7 @@ Access tokens are valid for 7 days; refresh tokens for 365 days. `ValidateAdmin`
**Protected (auth required)** **Protected (auth required)**
| Method | Path | Description | | Method | Path | Description |
| --- | --- | --- | | --- | --- | --- |
| POST | `/api/messages/upload` | Upload message file (rate limited: 5/min) | | POST | `/api/messages/upload` | Upload a file for a chat message or a canvas box (rate limited: 30/min, burst 20) |
**Admin (auth + admin required)** **Admin (auth + admin required)**
| Method | Path | Description | | Method | Path | Description |
+7 -3
View File
@@ -89,8 +89,12 @@ http {
# (Production only; the dev template omits it. # (Production only; the dev template omits it.
# Its location is at the bottom of this file, # Its location is at the bottom of this file,
# not in the shared route table.) # not in the shared route table.)
# upload 5r/m burst=3 - uploads are 50MB-capable and hit disk; this # upload 30r/m burst=20 - uploads hit disk; this bounds how fast one IP
# bounds how fast one IP can fill the volume. # can fill the volume. Generous because only a
# signed-in user can upload and accounts are
# admin-created, and because dropping a batch of
# pictures onto a canvas page uploads them all
# at once — the burst lets ~20 through together.
# hotel_search 3r/m burst=2 - each request holds an upstream call to # hotel_search 3r/m burst=2 - each request holds an upstream call to
# Travelodge/TfL for up to a few minutes and the # Travelodge/TfL for up to a few minutes and the
# Python side has a single search slot, so this is # Python side has a single search slot, so this is
@@ -109,7 +113,7 @@ http {
limit_req_zone $binary_remote_addr zone=login:10m rate=5r/m; limit_req_zone $binary_remote_addr zone=login:10m rate=5r/m;
limit_req_zone $binary_remote_addr zone=api:10m rate=30r/s; limit_req_zone $binary_remote_addr zone=api:10m rate=30r/s;
limit_req_zone $binary_remote_addr zone=graphql:10m rate=10r/s; limit_req_zone $binary_remote_addr zone=graphql:10m rate=10r/s;
limit_req_zone $binary_remote_addr zone=upload:10m rate=5r/m; limit_req_zone $binary_remote_addr zone=upload:10m rate=30r/m;
limit_req_zone $binary_remote_addr zone=hotel_search:10m rate=3r/m; limit_req_zone $binary_remote_addr zone=hotel_search:10m rate=3r/m;
log_format compact log_format compact
+1 -1
View File
@@ -54,7 +54,7 @@ http {
# kept equal to production so a limit that would bite there bites here too. # kept equal to production so a limit that would bite there bites here too.
limit_req_zone $binary_remote_addr zone=login:10m rate=5r/m; limit_req_zone $binary_remote_addr zone=login:10m rate=5r/m;
limit_req_zone $binary_remote_addr zone=api:10m rate=30r/s; limit_req_zone $binary_remote_addr zone=api:10m rate=30r/s;
limit_req_zone $binary_remote_addr zone=upload:10m rate=5r/m; limit_req_zone $binary_remote_addr zone=upload:10m rate=30r/m;
limit_req_zone $binary_remote_addr zone=hotel_search:10m rate=3r/m; limit_req_zone $binary_remote_addr zone=hotel_search:10m rate=3r/m;
log_format compact log_format compact
+1 -1
View File
@@ -148,7 +148,7 @@
} }
location $BACKEND_ENDPOINT/messages/upload { location $BACKEND_ENDPOINT/messages/upload {
limit_req zone=upload burst=3 nodelay; limit_req zone=upload burst=20 nodelay;
rewrite ^$BACKEND_ENDPOINT/(.*)$ /$1 break; rewrite ^$BACKEND_ENDPOINT/(.*)$ /$1 break;
proxy_pass $upstream_backend; proxy_pass $upstream_backend;
proxy_set_header Host $host; proxy_set_header Host $host;