From fc777ba8b2a16ecd1b3a0427e9bf1cd3280fd014 Mon Sep 17 00:00:00 2001 From: Adam French Date: Tue, 24 Nov 2026 16:33:42 +0000 Subject: [PATCH] Add a cloudflared connector for git.DOMAIN on the Gitea LXC Gitea gets its own remotely managed Cloudflare tunnel, run beside it on the LXC, so public HTTPS for git.DOMAIN no longer has to pass through stpvm. It is a separate tunnel from the site's, since a tunnel's connectors share all its hostnames. It sits behind the `tunnel` profile until git.DOMAIN is the canonical address, so a routine `docker compose up -d` does not publish it early. Co-Authored-By: Claude Opus 5.5 --- gitea/.env.example | 5 +++++ gitea/docker-compose.yml | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/gitea/.env.example b/gitea/.env.example index dde6b49..2b65aca 100644 --- a/gitea/.env.example +++ b/gitea/.env.example @@ -28,3 +28,8 @@ GITEA_SSH_DOMAIN= # file's extra_hosts). DOMAIN= EDGE_IP= + +# Token of Gitea's own Cloudflare tunnel (NOT the site's CLOUDFLARE_TUNNEL_TOKEN), +# from Zero Trust -> Networks -> Tunnels -> the stpgit tunnel. Used by the +# cloudflared service (profile `tunnel`), which serves https://git.DOMAIN. +GITEA_TUNNEL_TOKEN= diff --git a/gitea/docker-compose.yml b/gitea/docker-compose.yml index 076e95d..1fb31cf 100644 --- a/gitea/docker-compose.yml +++ b/gitea/docker-compose.yml @@ -124,3 +124,29 @@ services: depends_on: gitea-db: condition: service_healthy + + # Public HTTPS for git.DOMAIN through Gitea's OWN Cloudflare tunnel, so the + # public Gitea no longer passes through stpvm. Remotely managed: the + # hostname -> origin mapping (git.DOMAIN -> http://gitea:3000) lives in the + # Zero Trust dashboard and only the token is here. It must be a separate + # tunnel from the site's: connectors of one tunnel share all its hostnames, + # so a second connector here would be sent www traffic too. + # + # The tunnel carries HTTP only, with Cloudflare's 100 MB request-body cap, so + # SSH (2222), registry pushes and CI stay on the LAN/tailnet path above. + # + # Behind the `tunnel` profile until git.DOMAIN is the canonical address + # (ROOT_URL, the history-view protection), so a routine `docker compose up + # -d` does not publish it early: start it with + # docker compose --profile tunnel up -d + # and drop the profile once the cutover is done. + cloudflared: + image: cloudflare/cloudflared:2026.9.3 + container_name: gitea-cloudflared + profiles: ["tunnel"] + restart: always + command: ["tunnel", "--no-autoupdate", "run"] + environment: + - TUNNEL_TOKEN=${GITEA_TUNNEL_TOKEN:-} + depends_on: + - gitea