Client address is the right-most untrusted X-Forwarded-For entry (closes #144)
check / check (push) Canceled after 0s

From a peer in TRUSTED_PROXIES, clientIP took the left-most
X-Forwarded-For entry, which the client writes itself behind a proxy
that appends to the header, so a client could choose the address the
rate limit counts and the request log records. It now walks the entries
from the right past trusted proxies and takes the first that is not
one; with only trusted entries, or one that is not an address, it uses
the peer. Every X-Forwarded-For header line is read. X-Real-IP is read
only when there is no X-Forwarded-For entry. README.md Settings says
which entry is taken.

Model: opus-5-5
This commit is contained in:
2026-10-18 21:05:54 +00:00
parent e43a710114
commit d1ccea78fb
4 changed files with 108 additions and 17 deletions
+12
View File
@@ -21,6 +21,18 @@ Run `make frontend-viewport-test` in CI as its own step; it is not part of
# Completed Steps
- 2026-10-18: from a trusted proxy, the backend takes the client address from
the right-most `X-Forwarded-For` entry that is not in `TRUSTED_PROXIES`
([#144](https://git.eeqj.de/sneak/netwatch/issues/144)). It took the left-most
entry, which the client writes itself behind a proxy that appends to the
header, so a client could choose the address the rate limit counts and the
request log records. With only trusted addresses in the header, or an entry
that is not an IP address met on the way, the direct peer is used. `X-Real-IP`
is read only without `X-Forwarded-For`, and every `X-Forwarded-For` header
line is read, not only the first. The image's nginx, and the
`TRUSTED_PROXIES=127.0.0.1/32` it starts the backend with, are unchanged. Unit
tests resolve the address from chains ending in an untrusted address, in
trusted ones, of only trusted ones, and split over two header lines
- 2026-10-18: after an interval change, the summary's Reachable slot reads
`--/--` in white, as at page load, until the second round since the change
ends ([#140](https://git.eeqj.de/sneak/netwatch/issues/140)). It used to read