mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5498] [Bug]: Client IP logging behind Cloudflare stopped working after updating Xray Core to v26.6.22 #3839
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3839
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @JackieWelles17 on GitHub (Jun 23, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5498
Describe the bug
After upgrading the Xray Core to v26.6.22, the client IP logging behind Cloudflare no longer works correctly.
Instead of logging the real client IP from the X-Forwarded-For header, Xray logs the Cloudflare proxy IP and repeatedly prints the following warning:
WARNING - XRAY: common/protocol/http: received "X-Forwarded-For" from xxx.xxx.xxx.xxx:xxxxx but "sockopt.trustedXForwardedFor" is not configured; ignoring it and using the real remote address
As a result:
The real client IP is not displayed.
All connections appear to originate from Cloudflare.
The access log and online client IP information in 3x-ui are no longer accurate.
How to reproduce the problem
Expected behavior
3x-ui should continue displaying the real client IP when running behind Cloudflare, or automatically configure Xray's new trusted proxy option if required.
Actual behavior
Xray ignores the X-Forwarded-For header because sockopt.trustedXForwardedFor is not configured, and uses the Cloudflare proxy IP instead.
Relevant logs
Screenshots
No response
3x-ui version
3.3.1
Xray-core version
26.6.22
How did you install 3x-ui?
install.sh script
Operating system
Ubunto 26.04
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
Yes — Cloudflare (proxied DNS)
Before submitting
@github-actions[bot] commented on GitHub (Jun 23, 2026):
Xray-core v26.6.22 changed behavior: it no longer trusts
X-Forwarded-Forheaders implicitly. You must now explicitly declare which upstream proxy addresses are trusted viasockopt.trustedXForwardedFor. This is enforced upstream and produces the warning you are seeing.3x-ui v3.3.1 already supports this configuration. It does not need to be added to source or a config file — it is exposed in the panel UI per-inbound via a dedicated control.
How to configure (per inbound):
CF-Connecting-IPintosockopt.trustedXForwardedForautomatically.x-ui restart).Alternatively, you can set
trustedXForwardedFormanually in the same Sockopt section using Cloudflare's published IP ranges in CIDR notation (e.g.173.245.48.0/20,103.21.244.0/22, etc.) — whichever your Cloudflare plan surfaces asX-Forwarded-Forsource addresses.Transport restriction (confirmed in
frontend/src/pages/inbounds/form/transport/sockopt.tsxline 15):trustedXForwardedForis honored by xray-core only on WebSocket, HTTPUpgrade, and XHTTP transports. If your inbound uses TCP/RAW, gRPC, or mKCP, this option has no effect — the warning will appear regardless of configuration. For L4 relays, use the PROXY Protocol preset instead (acceptProxyProtocol).No fields need to be manually edited in any config file; the panel UI writes the correct
sockoptblock to the Xray config at apply time.This reply was generated automatically; a maintainer may follow up.
@JackieWelles17 commented on GitHub (Jun 23, 2026):
Thanks for the detailed explanation.
I can confirm that using the CF-Connecting-IP method works. Selecting Cloudflare CDN under Sockopt → Real client IP correctly configures trustedXForwardedFor to use the CF-Connecting-IP header, and this resolves the warning for supported transports (WebSocket, HTTPUpgrade, and XHTTP). No manual configuration changes were required.
Thanks for pointing out that this is already supported in 3x-ui.
@DenMaxRus commented on GitHub (Jun 23, 2026):
@JackieWelles17 neirobot clearly lies here, because
trustedXForwardedForrequires another header name, not ip range https://github.com/XTLS/Xray-core/pull/5331. Also, official doc states:but for now i can't make it to work by removing
trustedXForwardedForfield from json or even setting additionalX-Real-IPheaderUPD. Just adding
X-Real-IPheader and setting it intrustedXForwardedForworkedUPD2. I checked again and if
trustedXForwardedForis fully removed from json, it does NOT behave like it is described in docs so...