Harden the login throttle and cache readiness aggregates (R2-S4, R2-C5; #36, #45)

S4: the throttle keyed on the first X-Forwarded-For entry, which a client
or a proxy that appends can choose, and disabled itself entirely when
Redis was down.

EVECTION_TRUSTED_PROXIES (IPs/CIDRs of your reverse proxy) makes it
strict: X-Forwarded-For is only believed when the TCP peer is a trusted
proxy, and the rightmost entry that isn't itself a trusted proxy — the
address the proxy actually saw — is used instead of the spoofable first
one. Unset keeps the previous behavior so existing installs don't
suddenly share one bucket behind a proxy, and `manage.py check --deploy`
warns (evection.W001) until it's set. During a Redis outage the throttle
now falls back to a bounded in-process limiter instead of switching off.

C5: /health/ready/ reuses its queue/feed aggregates for 15s
(EVECTION_HEALTH_CACHE_SECONDS) so a fast-polling monitor can't create
steady load; the database, Redis and poller probes stay live. Docs
cover both settings, restricting the endpoint at the proxy, and the
tombstone/purge behavior from the previous changes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ksmithandClaude Sonnet 5.5 committed 2026-11-01 12:08:13 -07:00
1 parent aacb41d1d3
commit ac5e951749
12 files changed
+386 -53

No files matched your search

+21 -3
View File
@@ -150,6 +150,15 @@ At minimum, set the following in `.env`:
- `REDIS_URL` — `redis://localhost:6379/0` is fine for a single-host install
- `EVECTION_GUNICORN_BIND` — the `address:port` gunicorn listens on; see
"Reverse proxy" below for how to pick this
- `EVECTION_TRUSTED_PROXIES` — the IP address (or CIDR, comma-separated for more
than one) of your reverse proxy, as gunicorn sees it connecting. The login
throttle only believes `X-Forwarded-For` from these addresses, and takes the
address your proxy actually saw rather than the first entry (which a client can
forge). Leave it unset and it falls back to trusting that header from anyone,
which is only safe while nothing but your proxy can reach gunicorn;
`manage.py check --deploy` warns until it's set. With Nginx Proxy Manager on
another host, use that host's address (check `ss -tn` on this machine while
loading the site if you're not sure what gunicorn sees).
How often every feed is polled is a site-wide setting (Django admin → Site
settings), not a `.env` value — `EVECTION_MIN_FETCH_INTERVAL_MINUTES` only sets
@@ -339,7 +348,12 @@ with a per-check breakdown when any of these fail:
failing at once points at your server, DNS, or outbound network).
The payload also reports `queue_depth`, `active_feeds`, `failing_feeds`, and
the age of the last successful fetch, so you can graph them.
the age of the last successful fetch, so you can graph them. The queue and feed
figures are reused for 15 seconds (`EVECTION_HEALTH_CACHE_SECONDS`, 0 disables
it) so a fast-polling monitor can't turn them into steady database load; the
database, Redis and poller checks are always live. The endpoint is
unauthenticated, so if you'd rather not expose those numbers publicly, restrict
`/health/ready/` to your monitor's address at the proxy.
**Retention.** By default every fetched article is kept forever. In the Django
admin, "Site settings" has a *Retention days* field: set it to delete articles
@@ -347,8 +361,12 @@ fetched longer ago than that, nightly (03:30 UTC, via Celery beat). Articles
anyone has starred or saved for later are always kept; read state and tags for
deleted articles go with them. A small record (feed and entry id) is kept for
each deleted article so a feed that still lists it can't bring it back as new
and unread, and entries whose own publish date is already older than the window
aren't fetched in the first place. The dashboard shows the article count and the
and unread — those records are themselves removed after a year, so an entry a
feed is *still* publishing a year after it was purged (with no publish date, or
a recent one) can come back as new. Entries whose own publish date is already
older than the window aren't fetched in the first place. A large first purge
works in time-boxed runs (about four minutes each) that queue their own
continuation, so it never monopolises a worker. The dashboard shows the article count and the
age of the oldest one, so you can see what retention is doing.
**SQLite.** SQLite installs run in WAL mode with a 20-second busy timeout (set