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"