Client address is the right-most untrusted X-Forwarded-For entry (closes #144)
check / check (push) Waiting to run

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
+7 -1
View File
@@ -212,7 +212,13 @@ replaces the default; set and empty, the server trusts no proxy. Loopback is not
in the default, so a reverse proxy on the same host has to be named, as in
`TRUSTED_PROXIES=127.0.0.1/32`. A request whose direct peer is outside this set
has its forwarded headers ignored, and the direct peer is logged and
rate-limited instead. The container image does not use this default; see
rate-limited instead. From a direct peer inside the set, the client address is
the right-most `X-Forwarded-For` entry that is not in the set: each proxy
appends the address it took the request from, so the entries further left were
written by the client and are not used. If the search from the right finds only
addresses in the set, or meets an entry that is not an IP address, the direct
peer is used. `X-Real-IP` is read only when `X-Forwarded-For` is missing or
empty. The container image does not use this default; see
[Deployment](#deployment).
A variable set to a value the server cannot use, such as `PORT=abc`,