Skip to content

Fix/umami analytics header forwarding - #4205

Merged
kusssal merged 2 commits into
developfrom
fix/umami-analytics-header-forwarding
Aug 27, 2026
Merged

Fix/umami analytics header forwarding#4205
kusssal merged 2 commits into
developfrom
fix/umami-analytics-header-forwarding

Conversation

@mesudip

@mesudip mesudip commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

List of changes

  • Improve handling of forwarded IP headers
  • Log now show forward chain in addition to the client-ip

Checklist

  • related issue
  • My changes generate no new warnings
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the changelog
  • I have added tests that prove my fix is effective or that my feature works

Behind a CDN/ingress/load balancer, nginx's $remote_addr is the proxy
address, so the X-Real-IP header forwarded to Umami (which Umami
prioritizes over X-Forwarded-For) identified the ingress as the
visitor, breaking country/location analytics.

Add opt-in real-IP resolution driven by deployment configuration:

- TRUSTED_PROXY_CIDRS: comma- or space-separated list of trusted proxy
  CIDRs, emitted as set_real_ip_from directives (invalid entries are
  skipped with a warning)
- REAL_IP_HEADER: header to recover the client IP from (default
  X-Forwarded-For), with real_ip_recursive on

When set, $remote_addr resolves to the true client address and the
existing X-Real-IP forwarding becomes correct. Unset, behavior is
unchanged.
…es, log XFF

- Apply set_real_ip_from/real_ip_header only inside the /x/ Umami proxy
  location, so $remote_addr for all other routes remains the direct
  peer and no client-supplied header is trusted outside analytics.
- Default TRUSTED_PROXY_CIDRS to the private ranges reverse proxies
  normally connect from (10/8, 172.16/12, 192.168/16, fc00::/7) so the
  fix works out of the box behind in-cluster ingresses; internet
  clients cannot spoof these as source addresses. Set
  TRUSTED_PROXY_CIDRS=none to disable real IP resolution entirely.
- Extend the access log format to append xff="$http_x_forwarded_for",
  recording the proxy-reported client chain verbatim alongside the
  direct peer address without trusting it.
@kusssal
kusssal merged commit 835efd1 into develop Aug 27, 2026
8 checks passed
@kusssal
kusssal deleted the fix/umami-analytics-header-forwarding branch August 27, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants