Private
Public Access
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>
This commit is contained in:
1 parent
cb5617edb8
commit
ca03a5994b
2 files changed
+44
-7
No files matched your search
@@ -50,7 +50,15 @@ server {
|
||||
proxy_pass http://127.0.0.1:8000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# $remote_addr, not $proxy_add_x_forwarded_for (S8): the latter
|
||||
# APPENDS to whatever X-Forwarded-For a client already sent, so a
|
||||
# client could set their own "X-Forwarded-For: 1.2.3.4" and have it
|
||||
# forwarded as the first (trusted) hop — Evection's login rate
|
||||
# limiter (apps.accounts.views._client_address) and anything else
|
||||
# that reads this header take the first entry as the real client
|
||||
# address. Overwriting it with nginx's own view of the connecting
|
||||
# IP is what actually makes that trust meaningful.
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user