Pass the browser's address to the mail server, and trust IPv4 proxies on a dual-stack socket #115

Merged
jcoffey-dev merged 2 commits from feat/forward-client-ip into main 2026-11-19 03:00:29 +00:00
2 Commits
Author SHA1 Message Date
jcoffey-dev 774a2de094 Trust IPv4 proxies on a dual-stack socket
ci / node (pull_request) Skipped
ci / version (pull_request) Skipped
ci / docker-build (pull_request) Skipped
ci / publish (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 1m45s
ci / announce (pull_request) Skipped
The image listens on ::, where Node reports an IPv4 peer as
::ffff:10.0.0.5. No IPv4 range matches that form, so every proxy reaching
the webmail over IPv4 looked untrusted: its X-Forwarded-For was ignored and
the proxy itself became the client. Behind Caddy, nginx or an ingress, all
users then shared one sign-in limit and one address in the logs.

The peer is now read in its plain IPv4 form, as the forwarded chain
already was.
2026-11-18 19:41:12 -07:00
jcoffey-dev ce9f8a523f Tell the mail server who each request is for (X-Forwarded-For)
Every request the webmail makes comes from the webmail's own address, so
the server's limits and bans counted all of a replica's users as one
client: a hundred wrong passwords in a day between them, or a hundred new
tokens in a minute, locked everyone on that replica out.

Requests to the mail server now carry X-Forwarded-For with the client
address the webmail resolved (TRUSTED_PROXIES), replacing any the browser
sent. Fetches for remote images and calendars never carry it.

README: how the limits behave with several replicas (K-W3).
2026-11-18 19:18:03 -07:00