From 79a90112121581875e050f671fd6d0f6d2ec6f05 Mon Sep 17 00:00:00 2001 From: Adam French Date: Sun, 25 Oct 2026 01:17:31 +0000 Subject: [PATCH] Fix the tunnel's error 1000 and notes sync, move maintenance to 05:00 nginx's network aliases for the public names vanish while it is stopped, so cloudflared fell through to public DNS, got Cloudflare's own IPs and visitors saw error 1000 on every deploy. nginx now has a fixed address and cloudflared pins both names to it, so a stopped nginx is a plain 502. The same aliases sent silverbullet-git's pushes to ssh://DOMAIN:2222 to nginx, which has no 2222: nothing has pushed since 2026-10-15. It now maps DOMAIN to the host gateway, where gitea publishes that port. The weekly maintenance restarts dockerd and every container; at 01:00 it kept catching late-night SilverBullet saves. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/maintenance.yaml | 5 ++++- DEPLOYMENT.md | 11 +++++++++++ docker-compose.yml | 21 +++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/maintenance.yaml b/.gitea/workflows/maintenance.yaml index 03b9e89..03c8c73 100644 --- a/.gitea/workflows/maintenance.yaml +++ b/.gitea/workflows/maintenance.yaml @@ -2,7 +2,10 @@ name: Weekly Maintenance on: schedule: - - cron: "0 1 * * 0" + # 05:00 UTC Sunday (06:00 in BST). The upgrade restarts dockerd and + # every container, so it runs when nobody is likely to be mid-edit; + # 01:00 kept catching late-night SilverBullet saves. + - cron: "0 5 * * 0" workflow_dispatch: jobs: diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 026088b..4b568bc 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -275,6 +275,17 @@ 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. +An alias only exists while nginx is running, so cloudflared also pins both +names to nginx's fixed address (`172.28.255.251`) with `extra_hosts`. Without +that, while nginx is stopped for a deploy or the weekly maintenance, the name +falls through to public DNS, resolves to Cloudflare itself, and visitors see +Cloudflare error 1000 instead of a 502. + +The aliases have a side effect for anything else on `app-network` that uses +the public name for a port nginx does not serve. `silverbullet-git` pushes to +Gitea's SSH on `:2222`, so it maps `` to the host gateway +instead, where Gitea publishes that port. + Setup, once: 1. Cloudflare dashboard → the domain must be on Cloudflare DNS. diff --git a/docker-compose.yml b/docker-compose.yml index 88e30dc..bd4495d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -146,6 +146,11 @@ services: aliases: - ${DOMAIN} - www.${DOMAIN} + # Fixed for cloudflared's extra_hosts (see there): an alias only + # exists while nginx is running, and this address is pinned to the + # same names for when it is not. Top of the /16 beside cloudflared's, + # away from docker's dynamic allocations. + ipv4_address: 172.28.255.251 ports: - 80:80 - 443:443 @@ -227,6 +232,15 @@ services: - TUNNEL_TOKEN=${CLOUDFLARE_TUNNEL_TOKEN:-} depends_on: - nginx + # Pins the tunnel origin's names to nginx's fixed address. nginx's aliases + # vanish while it is stopped (every deploy and the weekly maintenance), and + # docker's DNS then forwards the name to public DNS, which answers with + # Cloudflare's own IPs: the tunnel sent requests back to the edge and + # visitors got error 1000. /etc/hosts wins over DNS, so a stopped nginx is + # now a refused connection, which cloudflared reports as a plain 502. + extra_hosts: + - "${DOMAIN}:172.28.255.251" + - "www.${DOMAIN}:172.28.255.251" networks: app-network: ipv4_address: 172.28.255.250 @@ -453,6 +467,13 @@ services: restart: always networks: - app-network + # The vault's remotes are ssh://git@DOMAIN:2222/..., but nginx's network + # aliases make DOMAIN resolve to nginx on app-network, which has no :2222, + # so every pull and push was refused. /etc/hosts wins over Docker's DNS, so + # this sends DOMAIN back to the host, where gitea publishes 2222. The name + # is unchanged, so known_hosts still matches. + extra_hosts: + - "${DOMAIN}:host-gateway" # Same uid SilverBullet writes as, so commits don't leave root-owned objects # in .git that the host user can no longer clean up. user: "1000:1000"