Redirect /gitea/ to git.DOMAIN instead of proxying Gitea
Test and deploy / test (push) Successful in 21s
Test and deploy / deploy (push) Successful in 8s

Gitea's ROOT_URL is now https://git.DOMAIN/, served by the Gitea LXC's own
tunnel, so Caddy stops proxying /gitea/ and 301s every /gitea/* URL there
with the prefix dropped and the query kept (CV links, HTTPS clones,
bookmarks). The admin gate on Gitea's commit-history views goes with the
proxy; on git.DOMAIN they are public by choice. The registry at the apex's
/v2/ is still proxied. edge_test.sh checks the redirects instead of the
gate, and the docs and architecture diagrams follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-24 17:21:13 +00:00
co-authored by Claude Opus 5.5
parent bb83c6bb03
commit 180f6ac8b8
7 changed files with 41 additions and 52 deletions
+6 -5
View File
@@ -177,7 +177,7 @@
}
# ---- Admin gate (/sb/, /jobs/, /tracker/, /dozzle/, /garage/, /radio/admin/,
# Gitea's history views, /uploads/private/) ----
# /uploads/private/) ----
# forward_auth sends a GET carrying the original request's headers, cookie
# included, to the backend's /auth/validate-admin before the request goes
# anywhere. 2xx lets it through; 401/403 become a redirect to the SPA login.
@@ -231,10 +231,11 @@
# Production only (sites/prod.caddy); HSTS on localhost would poison the
# browser for every other localhost project on the machine.
#
# No site-wide CSP here. Gitea (proxied at /gitea/) relies on inline <script>
# blocks its own templates generate, so a shared script-src would need
# 'unsafe-inline', which voids almost all of CSP's value. If a real CSP
# matters again, give the SPA document its own, separate from Gitea.
# No site-wide CSP here. It was left out because Gitea, proxied at /gitea/
# until 2026-11-24, relies on inline <script> blocks its own templates
# generate, so a shared script-src would need 'unsafe-inline', which voids
# almost all of CSP's value. Gitea now lives on git.DOMAIN and /gitea/ only
# redirects, so that reason is gone; a real CSP for the SPA is now possible.
(security_headers) {
header {
X-Frame-Options "SAMEORIGIN"
+12 -8
View File
@@ -148,9 +148,6 @@ echo "# admin gate, signed out: must redirect to the login, with the original UR
for p in \
/sb/ /sb/index.html /jobs/ /jobs/api/graphql /tracker/ /tracker/dashboard \
/dozzle/ /garage/ /radio/admin/stats.xsl /uploads/private/x.png \
/gitea/adamf/web_server/commit/0000000 /gitea/adamf/web_server/src/commit/0000000/README.md \
/gitea/adamf/web_server/archive/main.tar.gz /gitea/adamf/web_server/compare/main...x \
/gitea/adamf/web_server/blame/commit/0000000/README.md \
"/jobs/leads?x=1"; do
must 302 "$LOGIN$p" gate "$p"
done
@@ -161,21 +158,29 @@ must 302 "${LOGIN}/receipt/" permission /receipt/
if [ -n "${EDGE_COOKIE:-}" ]; then
echo "# admin gate, signed in: must be let through"
for p in /sb/ /jobs/ /tracker/ /dozzle/ /garage/ /radio/admin/stats.xsl \
/gitea/adamf/web_server/commit/0000000 /receipt/; do
/receipt/; do
not_login gate "$p" -H "Cookie: $EDGE_COOKIE"
done
fi
echo "# carve-outs and public routes (status depends on the upstream)"
for p in /jobs/api/capture /jobs/job-capture.user.js /tracker/api/v1/events \
/tracker/tracker.user.js /tracker/readyz /usaco/ /notes/ /gitea/ \
/gitea/adamf/web_server/src/branch/main/README.md /radio/status.xsl \
/tracker/tracker.user.js /tracker/readyz /usaco/ /notes/ /radio/status.xsl \
/py/ /py/docs /api/ /api/me /; do
show public "$BASE$p"
done
echo "# Gitea moved to git.<domain>: every /gitea/ URL must 301 there, prefix dropped"
GIT_HOST=${BASE#*://}
GIT="https://git.${GIT_HOST#www.}"
must 301 "$GIT/" gitea /gitea
must 301 "$GIT/" gitea /gitea/
must 301 "$GIT/adamf/web_server/src/branch/main/README.md" gitea /gitea/adamf/web_server/src/branch/main/README.md
must 301 "$GIT/adamf/web_server.git/info/refs?service=git-upload-pack" gitea "/gitea/adamf/web_server.git/info/refs?service=git-upload-pack"
must 301 "$GIT/adamf/web_server/commit/0000000" gitea /gitea/adamf/web_server/commit/0000000
echo "# bare prefixes and moved URLs"
for p in /api /radio /dozzle /garage /gitea /notes /sb /py /jobs /usaco \
for p in /api /radio /dozzle /garage /notes /sb /py /jobs /usaco \
/tracker /receipt /cv/jobs /cv/leads /job-capture.user.js "/gitea?x=1"; do
show redirect "$BASE$p"
done
@@ -187,7 +192,6 @@ done
hdr "$BASE/" Content-Type Strict-Transport-Security X-Frame-Options \
X-Content-Type-Options Referrer-Policy Content-Security-Policy Server
hdr "$BASE/api/" Strict-Transport-Security X-Frame-Options Server
hdr "$BASE/gitea/" Strict-Transport-Security X-Frame-Options Server
hdr "$BASE/assets/does-not-exist.js" Cache-Control
hdr "$BASE/img/stamps/mine.gif" Access-Control-Allow-Origin Cache-Control
+11 -23
View File
@@ -111,7 +111,7 @@ redir {$BACKEND_ENDPOINT} {$BACKEND_ENDPOINT}/ 301
redir /radio /radio/ 301
redir /dozzle /dozzle/ 301
redir /garage /garage/ 301
redir /gitea /gitea/ 301
redir /gitea https://git.{$DOMAIN}/ 301
redir /notes /notes/ 301
redir /sb /sb/ 301
redir /py /py/ 301
@@ -215,23 +215,6 @@ handle /radio/admin/* {
}
}
# Gitea's history views and archives. A crawler swarm (129k requests from
# 103k IPs over 2026-10-18/19, so per-IP rate limits are useless) walks every
# file at every commit, and those pages are the expensive ones: diffs, blame,
# tarballs. 89% of its requests were these shapes. People browsing the code
# use the branch views (src/branch/..., commits/branch/...), which stay
# public, so the CV's repo links still work. Gitea's own
# REQUIRE_SIGNIN_VIEW=expensive would also block src/branch, hence doing it
# here. Ahead of /gitea/*.
@gitea_history path_regexp ^/gitea/[^/]+/[^/]+/((src|raw|blame|commits|media)/commit/|commit/|archive/|compare/)
handle @gitea_history {
import admin_gate
uri strip_prefix /gitea
reverse_proxy {$GITEA_HOST}:{$GITEA_PORT} {
import proxy
}
}
# SilverBullet: the admin-only EDITOR for the vault /notes/ publishes. NO
# prefix strip: it is a PWA told its own base path via SB_URL_PREFIX=/sb, and
# builds its service-worker scope and asset URLs from it. Strip the prefix and
@@ -252,11 +235,16 @@ handle /radio/* {
}
}
handle /gitea/* {
uri strip_prefix /gitea
reverse_proxy {$GITEA_HOST}:{$GITEA_PORT} {
import proxy
}
# Gitea moved to its own address on 2026-11-24: git.DOMAIN, served by the
# Gitea LXC's own Cloudflare tunnel (the adamf/stpgit repo), and its ROOT_URL.
# Every old link (the CV's, HTTPS clone URLs, bookmarks) is sent there with the
# prefix dropped and the query kept; git follows the redirect on a clone. This
# edge no longer proxies Gitea's pages, so the admin gate that used to sit on
# its commit-history views and archives (a crawler swarm walked them in
# 2026-10) went with it: on git.DOMAIN they are public by choice. The registry
# at the apex's /v2/ (sites/prod.caddy) is still proxied from here.
handle_path /gitea/* {
redir https://git.{$DOMAIN}{uri} 301
}
# The public notes viewer, behind the denials at the top of this file. No