From 33ea8a9b99d77c0c7a4ea94241dd6b9c806c26b9 Mon Sep 17 00:00:00 2001 From: Adam French Date: Wed, 14 Oct 2026 16:39:43 +0100 Subject: [PATCH] Correct the registry setup notes: the token realm is on the apex Gitea advertises its token endpoint at https:///v2/token, not under /gitea/, so the /v2/ route belongs in the apex server block (added in web_server da2ab9f) rather than nginx_routes.conf. Co-Authored-By: Claude Opus 5.5 --- README.md | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index e7f1444..23bb2f2 100644 --- a/README.md +++ b/README.md @@ -78,29 +78,20 @@ To pin a version instead of `latest`, set `JOBS_IMAGE_TAG=` in the site's ` ### One-off: registry setup -The image lives in this Gitea's container registry. Gitea is served under `/gitea/`, but Docker always talks to `/v2/` at the root of the host. So the site's nginx needs a `/v2/` route before anything can be pushed or pulled. +The image lives in this Gitea's container registry. Two things make that less simple than it sounds: + +- Docker always talks to `/v2/` at the root of the host, whatever Gitea's `ROOT_URL` says (`/gitea/`). +- Gitea advertises its token endpoint at `https://adam-french.co.uk/v2/token`, on the apex domain. The site redirects the apex to `www`. + +So the apex server block in web_server's `nginx/nginx.conf.template` proxies `/v2/` to Gitea and redirects everything else. That was added in web_server commit `da2ab9f`. 1. **Check Gitea's registry is on.** On the Pi, bypassing nginx: ``` curl -si http://localhost:3000/v2/ | head -5 ``` - You want a `401` with `WWW-Authenticate: Bearer realm="https://adam-french.co.uk/gitea/v2/token"`. A `404` means packages are off: add `[packages]` with `ENABLED = true` to Gitea's `app.ini.template` and recreate Gitea. + You want a `401` with `Www-Authenticate: Bearer realm="https://adam-french.co.uk/v2/token"`. A `404` means packages are off: add `[packages]` with `ENABLED = true` to Gitea's `app.ini.template` and recreate Gitea. -2. **Route `/v2/` to Gitea.** Add this to `nginx/nginx_routes.conf.template` in web_server, beside the `/gitea/` block, and deploy. Token requests go to the realm Gitea advertises (`/gitea/v2/token`), which the existing `/gitea/` route already serves. - ```nginx - location /v2/ { - client_max_body_size 0; # image layers exceed the global 50M - proxy_request_buffering off; # stream uploads instead of spooling them - proxy_read_timeout 900s; - proxy_send_timeout 900s; - proxy_pass $upstream_gitea; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } - ``` - Then `curl -si https://adam-french.co.uk/v2/` should give the same `401` as step 1. A `200` with HTML means the request is still reaching the site's SPA. +2. **Check nginx routes it.** `curl -si https://adam-french.co.uk/v2/` should give the same `401`, not a `301` to `www`. If you are setting up a fresh site, the route to copy is `location /v2/` in the apex `server` block of `nginx/nginx.conf.template`. 3. **Make a token.** In Gitea, go to Settings → Applications and create a token with **package: read and write**. @@ -114,9 +105,9 @@ The image lives in this Gitea's container registry. Gitea is served under `/gite docker pull adam-french.co.uk/adamf/registry-test:1 ``` Delete the test package afterwards, from your profile → Packages → registry-test → Settings. If the push fails, the error says where: - - **`unauthorized`:** the token's scope is wrong, or `/gitea/v2/token` isn't reachable (it should answer `401`, not `404`). + - **`unauthorized`:** the token's scope is wrong, or `https://adam-french.co.uk/v2/token` isn't reaching Gitea (it should answer `401` or JSON, not a `301`). - **`413`:** the `client_max_body_size 0` line isn't in effect. - - **HTML or "invalid character '<'":** `/v2/` is still reaching the SPA. + - **HTML, a redirect, or "invalid character '<'":** `/v2/` is not reaching Gitea. 5. **Give CI the credentials.** In this repo's Settings → Actions → Secrets, add `REGISTRY_USER` (`adamf`) and `REGISTRY_TOKEN` (the token). The next push to `main` publishes the image.