From da2ab9fb1794cd22e9b38cd4e6bfb00b06e404de Mon Sep 17 00:00:00 2001 From: Adam French Date: Wed, 14 Oct 2026 16:37:22 +0100 Subject: [PATCH] Serve Gitea's container registry at /v2/ on the apex domain Docker clients always talk to /v2/ at the root of the host, whatever Gitea's ROOT_URL says, and Gitea advertises its token endpoint at https:///v2/token. The apex server block redirected everything to www, so the registry was unreachable. It now proxies /v2/ to Gitea, without a body size limit or request buffering, and redirects the rest as before. Needed to publish the job-tracker image. Co-Authored-By: Claude Opus 5.5 --- nginx/nginx.conf.template | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/nginx/nginx.conf.template b/nginx/nginx.conf.template index 8d0d496..fa5a640 100644 --- a/nginx/nginx.conf.template +++ b/nginx/nginx.conf.template @@ -170,7 +170,38 @@ http { add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always; - return 301 https://www.$DOMAIN$request_uri; + # Gitea's container registry, which publishes images such as + # $DOMAIN/adamf/job-tracker. Docker always talks to /v2/ at the root + # of the host, whatever Gitea's ROOT_URL says, and Gitea advertises + # its token endpoint at https://$DOMAIN/v2/token: on the apex, not + # under /gitea/ and not on www. So the apex serves /v2/ itself rather + # than redirecting it; a redirect on a blob upload is not something + # every Docker client follows. Everything else still goes to www. + # + # The redirect is a `location /` rather than the server-level return + # it used to be, because a server-level return runs before any + # location is chosen. The HSTS add_header above is inherited by both + # locations, which declare none of their own. + location /v2/ { + # Image layers are far larger than the http block's 50M, and are + # streamed to Gitea rather than spooled to disk first. + client_max_body_size 0; + proxy_request_buffering off; + proxy_read_timeout 900s; + proxy_send_timeout 900s; + # $upstream_gitea is set in nginx_routes.conf, which only the www + # server includes. + set $upstream_gitea http://$GITEA_HOST:$GITEA_PORT; + 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; + } + + location / { + return 301 https://www.$DOMAIN$request_uri; + } } server {