PhoenixKit 2.22.10: Real visitor IP addresses behind a proxy
PhoenixKit 2.22.10 fixes the IP addresses PhoenixKit records for visitors.
Behind nginx or inside a container, every visitor showed the proxy’s own address, for registration, logins, magic links, sessions and the other places PhoenixKit tracks IPs. When the request comes from a local or private address, PhoenixKit now reads the forwarded headers to find the real visitor.
Every self-registered user, whether by form, magic link or social sign-in, also had the word “unknown” stored as their registration IP when the address could not be read. The admin showed it as if it were an address instead of “No data”. No IP is stored in that case now.
Upgrading
Registration geolocation tracking needs your endpoint’s LiveView socket to pass :peer_data, for example websocket: [connect_info: [:peer_data, session: ...]]. The installer does not add it; without it the setting does nothing.
Full release notes: PhoenixKit 2.22.10
2.22.10 · 9 September 2026
Fixed
- Registration IP/geolocation tracking silently recorded “unknown” for
every self-registered user.
register_user_with_geolocation/2guarded onis_binary(ip_address)alone, and the socket/conn IP extractors return the literal string"unknown"— nevernil— when they can’t tell the visitor’s address. That literal string satisfied the guard and got written toregistration_ipas if it were a real IP, then rendered verbatim in the admin UI instead of “No data.” Self-registration, magic-link registration, and OAuth registration all funnel through this one function, so all three are fixed at once. - IP tracking now reads the visitor’s real address behind a reverse
proxy, everywhere it’s tracked.
IpAddress.extract_from_socket/1andextract_from_conn/1— used for registration, login, magic link, sessions, multi-session, live sessions, dashboard presence, the referral gate, and the admin user form — used to read the raw TCP peer, which behind nginx (or in a container) is the proxy’s own address for every visitor. They now delegate to the already-proxy-awareclient_address_from_socket/1/client_address/1, which readx-forwarded-for/x-real-ipwhen the peer is a loopback or private address. - Documented that
track_registration_geolocationrequires the host endpoint’s LiveView socket to declare:peer_datainconnect_info—mix phoenix_kit.installdoesn’t (and can’t) set this up automatically, and without it the setting silently does nothing.
PhoenixKit 2.22.10. Install or update: {:phoenix_kit, "~> 2.22"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.