Commit Graph
3 Commits
Author SHA1 Message Date
ksmithandClaude Sonnet 5 ca03a5994b Stop nginx from forwarding a client-spoofable X-Forwarded-For (S8)
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>
2026-10-31 15:27:36 -06:00
ksmithandClaude Sonnet 5 21c33e8188 Make the reverse proxy a required, pluggable part of every deployment
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>
2026-10-31 09:01:46 -06:00
ksmithandClaude Sonnet 5 3f6474ce94 Add hardening and deployment: admin dashboard, security headers, install docs
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>
2026-10-30 20:10:31 -06:00