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>
docs/install.md still showed 'git fetch --tags --force' and a bare
'pip install .', reintroducing the rewritten-tag and unpinned-dependency
risks the scripts closed. The manual steps now use a non-forced fetch
(with an explanation of what a clobber error means) and the hash-pinned
requirements.txt install followed by pip install --no-deps.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
/health/ready/ proved beat and a worker were alive but not that
fetching worked: every feed could be failing, or the queue could be
hours behind, and it would still report ok.
apps.core.health adds three checks: Celery queue depth (real Redis list
length, over 1000 fails), a successful fetch within three poll intervals
(30 min minimum, with a grace period for a brand-new install), and the
share of active feeds failing (over half, once there are at least four).
The payload also reports queue depth, active/failing feed counts, and
the age of the last successful fetch. Verified against real Redis with
queued Celery tasks, and the suite on PostgreSQL. docs/install.md lists
each check.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Articles and full HTML bodies accumulated forever, growing the
database, search index, and backups without bound. Site settings gets
a "Retention days" field (0, the default, keeps everything); a nightly
beat task deletes articles fetched longer ago than that in bounded
chunks, always keeping anything a user starred or saved for later.
Read state and tags cascade with the article and the FTS triggers drop
search entries. The dashboard shows the article count and oldest
article's age, and docs/install.md covers retention, the readiness
check, and SQLite's WAL tuning.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
docs/install.md covered the raw-nginx case via nginx.conf.example, but
gave no concrete guidance for Nginx Proxy Manager specifically, whose
generated config also defaults to the appending (spoofable) form of
X-Forwarded-For — the same production deployment this review is based
on uses NPM. Documents the Advanced tab / Custom Nginx Configuration
override, why it takes effect ahead of NPM's own default header, and a
note for anyone with something in front of NPM itself.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The example nginx config set X-Forwarded-For to $proxy_add_x_forwarded_for,
which APPENDS to whatever X-Forwarded-For a client already sent rather
than replacing it. A client could send its own "X-Forwarded-For:
1.2.3.4" and have it forwarded as the first (trusted) entry — exactly
what apps.accounts.views._client_address reads to key the login rate
limiter, letting an attacker spoof a different address on every request
to dodge the per-address throttle. Changed to $remote_addr, nginx's own
view of who actually connected, which overwrites rather than appends.
docs/install.md's "different host" proxy guidance also gets a concrete
ufw example instead of just "firewall that port" prose, explains why
that firewall rule isn't optional (gunicorn trusts whoever can reach it
directly as if they were the proxy), and documents an optional Unix
socket setup for the same-host case for anyone who wants gunicorn
unreachable by anything but the proxy, not just this nginx config.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Replaces Feed.fetch_interval_minutes with a single admin-editable
SiteSettings.fetch_interval_minutes (apps.core), following the same
singleton-row pattern as accounts.SetupLock. Per-feed error backoff is
unchanged — only the configured baseline interval is now shared across
every feed, loaded once per poll_due_feeds run rather than queried per
feed. EVECTION_MIN_FETCH_INTERVAL_MINUTES keeps working as the floor
underneath it.
SiteSettings is registered in Django admin as a singleton: "Add" is
only offered when no row exists yet, and delete is always refused.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Django's default LoginView had no throttle — an internet-facing
instance was exposed to unlimited password-guessing/credential-
stuffing attempts. apps.accounts.views.LoginView adds two independent,
Redis-cache-backed throttles (shared across all gunicorn workers,
unlike the per-process default LocMemCache): by client address (catches
one attacker spraying many usernames) and by the submitted username
(catches a distributed attack on one specific account). Either blocks
further attempts for a 5-minute window; both are generous enough not
to lock out a user who's just mistyped their own password a few times.
Client address prefers X-Forwarded-For's first hop, falling back to
REMOTE_ADDR — the same reverse-proxy trust boundary config.settings.prod
already relies on for X-Forwarded-Proto (gunicorn is never meant to be
reachable except through that proxy).
CACHES now points at Redis (already a hard install requirement for
Celery) instead of Django's implicit per-process default, since the
whole point is a shared counter across every gunicorn worker; test
settings override it back to LocMemCache so the suite doesn't need a
real Redis instance.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The release-notes reminder to manually bump this and restart gunicorn
was easy to miss or forget, leaving installed PWAs on a stale cached
shell/pages after an upgrade that changed static assets. upgrade.sh
now sets it to the deployed tag itself before restarting services, so
there's no manual step and no cache-invalidation window to miss.
install.sh does the same on first install for consistency.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
gunicorn previously only ever bound to a Unix socket, which assumes the
reverse proxy is nginx running on this same host — it can't be reached by
a proxy on a different machine at all (e.g. Nginx Proxy Manager on its own
box), which is this project's actual deployment target. Switch gunicorn to
listening on a plain TCP address instead, controlled by a new
EVECTION_GUNICORN_BIND setting in .env.
install.sh now asks whether the proxy is local or remote and picks a
sensible bind default either way (127.0.0.1:8000 vs 0.0.0.0:8000, with a
reminder to firewall the port in the remote case), and no longer tries to
automate nginx/certbot itself — docs/install.md's new "Reverse proxy"
section covers both shapes instead, since which proxy and where it runs is
the operator's choice, not something this script should assume or set up.
upgrade.sh's health check now curls the TCP bind instead of the old socket
path.
Also add WhiteNoise so gunicorn serves /static/ itself: the old approach
(nginx aliasing the staticfiles directory on disk) silently breaks the
moment the proxy isn't on this host and can't see this filesystem.
nginx.conf.example's own /static/ alias becomes an optional same-host perf
optimization rather than a requirement.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
On Debian/Ubuntu, python3-venv (ensurepip support) is a separate package
from python3 itself, and apt installing just python3 leaves venv creation
failing partway through install.sh — after the system user, chown, and
git checkout have all already happened. Check for it up front alongside
the Python version check, and document the apt package in install.md's
prerequisites.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
install.sh and upgrade.sh deploy git tags, not branch tips, but the docs
still described git pull/clone-and-run. Add a "Releases" section explaining
the v<year>.<month>.<day> tagging convention and that a tag must exist
before the first production install, update the manual upgrade steps to
match what upgrade.sh actually does (fetch tags, checkout latest), and
mention the /health/ endpoint upgrade.sh verifies against.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Keeps the traditional pip+systemd+nginx deployment (no Docker, per the
original decision) but automates the manual steps already in
docs/install.md instead of leaving them as copy-paste instructions:
- scripts/install.sh: creates the system user, virtualenv, generates
.env (auto SECRET_KEY, prompts for domain/SQLite-vs-Postgres —
non-interactive via EVECTION_ALLOWED_HOSTS/EVECTION_DATABASE_URL/etc
for scripted provisioning), migrates, collects static files, installs
the systemd units (sed-substituted for the actual install path/user
rather than hardcoded to /opt/evection), and optionally sets up nginx +
certbot. Safe to re-run — skips what's already done rather than
redoing it, and never overwrites an existing .env.
- scripts/upgrade.sh: git pull, reinstall, migrate, collectstatic,
restart whichever of the three services are actually present (handles
the combined worker+beat deployment variant too).
docs/install.md now leads with the script as the recommended path, with
the existing step-by-step instructions kept below for anyone who wants
to understand or customize what it's doing.
Verified: shellcheck clean on both scripts (via a throwaway shellcheck-py
venv, since neither apt nor pip --user were available non-interactively);
the systemd-unit and nginx-config sed substitutions produce correct
output against the real template files; the generated .env format
round-trips through `manage.py check` under config.settings.prod without
error. Did not actually run install.sh against a real system — that
creates a system user and installs systemd units, which needs the
person deploying it to run (and review) themselves.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds an admin-only dashboard (apps/core) surfacing feeds that are failing to
fetch, with error messages, subscriber counts, and a one-click retry that
resets backoff and re-queues the fetch.
Hardens config/settings/prod.py with the remaining standard Django security
settings (HSTS preload, nosniff, referrer-policy, frame-options, SameSite
cookies) plus a Content-Security-Policy header via django-csp, as a second
layer behind nh3's HTML sanitization of feed content.
Adds docs/install.md (pip + gunicorn + systemd + nginx, SQLite and Postgres
both covered) plus the systemd units and nginx snippet it references,
LICENSE (AGPL-3.0-or-later, matching pyproject.toml), and an updated README.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>