Follow-up to PR #4, which was merged just before these two commits landed — so main currently still has the hardcoded static Cloudflare IP list.
Now that caddy-cf bundles WeidiDeng/caddy-cloudflare-ip, this switches the Caddyfile to the dynamic cloudflare IP source, which auto-fetches and refreshes Cloudflare's IPv4/IPv6 ranges — no more 22-line static list to maintain.
Caddyfile: replace trusted_proxies static <22 ranges> with trusted_proxies cloudflare { interval 12h; timeout 15s }; keep client_ip_headers Cf-Connecting-Ip X-Forwarded-For with an explanatory comment.
docs/caddy-reverse-proxy.md: document the dynamic source as the primary example; note the static-list method as the fallback for builds without the plugin.
Verification
Confirmed http.ip_sources.cloudflare is present in the updated caddy-cf image.
caddy validate + caddy fmt clean.
Runtime-tested (Caddy -> SWS): starts cleanly (no error fetching CF IPs), serves HTTP 200 with gzip + security headers.
Scope note
Cherry-picked onto the current main so the diff is onlyCaddyfile + docs — it does not touch the media-optimization (#2) or audit-fix (#3) work already merged.
Follow-up to PR #4, which was merged just before these two commits landed — so `main` currently still has the hardcoded static Cloudflare IP list.
Now that `caddy-cf` bundles [`WeidiDeng/caddy-cloudflare-ip`](https://github.com/WeidiDeng/caddy-cloudflare-ip), this switches the Caddyfile to the dynamic `cloudflare` IP source, which auto-fetches and refreshes Cloudflare's IPv4/IPv6 ranges — no more 22-line static list to maintain.
```caddy
trusted_proxies cloudflare {
interval 12h
timeout 15s
}
client_ip_headers Cf-Connecting-Ip X-Forwarded-For
```
## Changes
- `Caddyfile`: replace `trusted_proxies static <22 ranges>` with `trusted_proxies cloudflare { interval 12h; timeout 15s }`; keep `client_ip_headers Cf-Connecting-Ip X-Forwarded-For` with an explanatory comment.
- `docs/caddy-reverse-proxy.md`: document the dynamic source as the primary example; note the static-list method as the fallback for builds without the plugin.
## Verification
- Confirmed `http.ip_sources.cloudflare` is present in the updated `caddy-cf` image.
- `caddy validate` + `caddy fmt` clean.
- Runtime-tested (Caddy -> SWS): starts cleanly (no error fetching CF IPs), serves HTTP 200 with gzip + security headers.
## Scope note
Cherry-picked onto the current `main` so the diff is **only** `Caddyfile` + docs — it does not touch the media-optimization (#2) or audit-fix (#3) work already merged.
## Deploy
After merge, reload the live proxy:
```bash
docker exec caddy_cf caddy reload --config /etc/caddy/Caddyfile
```
caddy-cf now includes WeidiDeng/caddy-cloudflare-ip, so replace the
hardcoded 22-range static list with 'trusted_proxies cloudflare' which
auto-fetches and refreshes Cloudflare's IPv4/IPv6 ranges (interval 12h,
timeout 15s). No static list to keep in sync when Cloudflare updates.
Kept client_ip_headers Cf-Connecting-Ip X-Forwarded-For (prefer CF's
authoritative end-user IP, fall back to XFF) and documented why.
Validated + fmt-clean and tested end-to-end against the updated caddy-cf
image: starts cleanly, serves HTTP 200 with gzip + security headers.
caddy-cf now bundles WeidiDeng/caddy-cloudflare-ip, so document
'trusted_proxies cloudflare { interval 12h; timeout 15s }' as the
primary (auto-refreshing) approach, with the static-list method noted
as the fallback for builds without the plugin. Also explains
client_ip_headers (Cf-Connecting-Ip preferred, X-Forwarded-For fallback).
ahmza
merged commit 4b0b681302 into main2026-07-25 04:09:11 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Follow-up to PR #4, which was merged just before these two commits landed — so
maincurrently still has the hardcoded static Cloudflare IP list.Now that
caddy-cfbundlesWeidiDeng/caddy-cloudflare-ip, this switches the Caddyfile to the dynamiccloudflareIP source, which auto-fetches and refreshes Cloudflare's IPv4/IPv6 ranges — no more 22-line static list to maintain.Changes
Caddyfile: replacetrusted_proxies static <22 ranges>withtrusted_proxies cloudflare { interval 12h; timeout 15s }; keepclient_ip_headers Cf-Connecting-Ip X-Forwarded-Forwith an explanatory comment.docs/caddy-reverse-proxy.md: document the dynamic source as the primary example; note the static-list method as the fallback for builds without the plugin.Verification
http.ip_sources.cloudflareis present in the updatedcaddy-cfimage.caddy validate+caddy fmtclean.Scope note
Cherry-picked onto the current
mainso the diff is onlyCaddyfile+ docs — it does not touch the media-optimization (#2) or audit-fix (#3) work already merged.Deploy
After merge, reload the live proxy:
caddy-cf now bundles WeidiDeng/caddy-cloudflare-ip, so document 'trusted_proxies cloudflare { interval 12h; timeout 15s }' as the primary (auto-refreshing) approach, with the static-list method noted as the fallback for builds without the plugin. Also explains client_ip_headers (Cf-Connecting-Ip preferred, X-Forwarded-For fallback).