Point the tunnel at the site's own name instead of No TLS Verify
Test and deploy / test (push) Successful in 1m45s
Test and deploy / deploy (push) Successful in 22s

nginx now carries DOMAIN and www.DOMAIN as aliases on app-network, so
cloudflared's origin can be https://www.DOMAIN: it resolves to nginx over
the bridge and the Let's Encrypt certificate verifies, with no TLS
overrides in the Cloudflare dashboard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-15 14:17:59 +01:00
co-authored by Claude Opus 5.5
parent 602aa522d6
commit 6d5420fab2
2 changed files with 35 additions and 20 deletions
+20 -16
View File
@@ -230,14 +230,20 @@ _remotely managed_ tunnel: the only thing in this repo is the token
(`CLOUDFLARE_TUNNEL_TOKEN`, editable from the Environment tab); hostnames and
origin settings live in the dashboard.
**Origin: `https://nginx:443`, with No TLS Verify.** Cloudflare terminates the
visitor's TLS at its edge, and cloudflared opens a second TLS connection to
nginx. That is deliberate. Pointed at `http://nginx:80`, the tunnel would hit
the HTTP→HTTPS redirect and loop. Going to :443 keeps every redirect, security
header and the `X-Forwarded-Proto: https` the backend's Secure cookies depend
on, and needs no nginx change. No TLS Verify is needed because cloudflared
dials the name `nginx`, which the certificate does not cover. The hop never
leaves `app-network`.
**Origin: `https://www.<DOMAIN>`, the site's own name.** Cloudflare
terminates the visitor's TLS at its edge, and cloudflared opens a second TLS
connection to nginx. That is deliberate. Pointed at `http://nginx:80`, the
tunnel would hit the HTTP→HTTPS redirect and loop. Going to :443 keeps every
redirect, security header and the `X-Forwarded-Proto: https` the backend's
Secure cookies depend on, and needs no nginx change.
The origin is the public name, not `nginx`, because nginx carries `<DOMAIN>`
and `www.<DOMAIN>` as network aliases on `app-network` (`docker-compose.yml`).
Inside the network those names resolve to the nginx container, so the hop
never leaves the Pi, and cloudflared verifies the Let's Encrypt certificate
against a name it covers. `https://nginx` would fail that check and need No
TLS Verify. The flip side: **an expired certificate now takes the tunnel down
with a 502**, which is why renewal over DNS-01 (step 5) matters.
Setup, once:
@@ -247,11 +253,10 @@ Setup, once:
3. Put it in `.env` as `CLOUDFLARE_TUNNEL_TOKEN` (or set it from the
Environment tab), then `docker compose up -d cloudflared`. The tunnel
shows as Healthy in the dashboard.
4. Add a public hostname per name, each with service `HTTPS`, URL
`nginx:443`, and under Additional application settings → TLS, **No TLS
Verify** on:
- `www.<DOMAIN>`: the site.
- `<DOMAIN>`: nginx redirects it to www, and it serves Gitea's registry
4. Add a public hostname per name, each with service `HTTPS` and its own
name as the URL, and no other settings:
- `www.<DOMAIN>` → `https://www.<DOMAIN>`: the site.
- `<DOMAIN>` → `https://<DOMAIN>`: nginx redirects it to www, and it serves Gitea's registry
at `/v2/`.
Creating each hostname replaces the existing A record for that name with
a CNAME to the tunnel. **That is the cutover**: until then the tunnel
@@ -268,9 +273,8 @@ Setup, once:
- **Certificate renewal.** Over DNS-01 with `CLOUDFLARE_DNS_API_TOKEN` set;
without it certbot falls back to HTTP-01, which needs port 80 forwarded.
The certificate still matters behind the tunnel: the registry path below
and any direct LAN access use it. (The tunnel itself would survive an
expired one, because of No TLS Verify.) A fresh machine with no
The certificate matters behind the tunnel: cloudflared verifies it, as
do the registry path below and any direct LAN access. A fresh machine with no
certificate at all boots the setup config (§3), which serves nothing over
443, so the tunnel carries nothing until the first issuance.
- **Registry pushes and pulls on the Pi.** Cloudflare caps request bodies at
+15 -4
View File
@@ -118,7 +118,17 @@ services:
- jobs
- activity-tracker
networks:
- app-network
app-network:
# The site's public names, resolving to this container for everything
# on app-network. They exist for cloudflared: its tunnel origin is
# https://www.DOMAIN, which lands here over the bridge with a name the
# Let's Encrypt certificate actually covers, so the tunnel verifies
# TLS with no extra dashboard settings (`https://nginx` would fail the
# name check). Any other container that calls the public site now
# reaches nginx directly instead of hairpinning through the internet.
aliases:
- ${DOMAIN}
- www.${DOMAIN}
ports:
- 80:80
- 443:443
@@ -160,9 +170,10 @@ services:
# forwards can be closed. The tunnel is "remotely managed": its public
# hostnames and origin settings live in the Cloudflare dashboard, and this
# container only needs the token. The routing set up there (DEPLOYMENT.md,
# "Cloudflare Tunnel") is https://nginx:443 with No TLS Verify, so nginx's
# config, redirects and security headers apply to tunnel traffic exactly as
# to direct traffic, and both paths work side by side.
# "Cloudflare Tunnel") is https://www.DOMAIN, which nginx's network aliases
# resolve to nginx itself, so the certificate verifies; nginx's config,
# redirects and security headers apply to tunnel traffic exactly as to
# direct traffic, and both paths work side by side.
#
# Fixed address so nginx can trust the CF-Connecting-IP header from this
# container and no other (set_real_ip_from in nginx.conf.template). It sits