[GH-ISSUE #5498] [Bug]: Client IP logging behind Cloudflare stopped working after updating Xray Core to v26.6.22 #3839

Closed
opened 2026-10-31 20:35:19 +07:00 by bsakaguchi · 3 comments
Owner

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

  1. Install or use 3x-ui.
  2. Configure traffic through Cloudflare.
  3. Upgrade Xray Core to 26.6.22.
  4. Connect a client through Cloudflare.
  5. Observe the Xray log.

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

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
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 1. Install or use 3x-ui. 2. Configure traffic through Cloudflare. 3. Upgrade Xray Core to 26.6.22. 4. Connect a client through Cloudflare. 5. Observe the Xray log. ### 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 ```shell ``` ### 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 - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:35:19 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jun 23, 2026):

Xray-core v26.6.22 changed behavior: it no longer trusts X-Forwarded-For headers implicitly. You must now explicitly declare which upstream proxy addresses are trusted via sockopt.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):

  1. Open the inbound in the panel → Edit.
  2. In the Stream Settings tab, scroll to Sockopt and enable it (toggle on).
  3. A Real client IP segmented control appears. Select Cloudflare CDN.
    • This writes CF-Connecting-IP into sockopt.trustedXForwardedFor automatically.
  4. Save and restart Xray (Restart in the panel, or x-ui restart).

Alternatively, you can set trustedXForwardedFor manually 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 as X-Forwarded-For source addresses.

Transport restriction (confirmed in frontend/src/pages/inbounds/form/transport/sockopt.tsx line 15): trustedXForwardedFor is 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 sockopt block to the Xray config at apply time.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4777865747 --> @github-actions[bot] commented on GitHub (Jun 23, 2026): Xray-core v26.6.22 changed behavior: it no longer trusts `X-Forwarded-For` headers implicitly. You must now explicitly declare which upstream proxy addresses are trusted via `sockopt.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):** 1. Open the inbound in the panel → **Edit**. 2. In the **Stream Settings** tab, scroll to **Sockopt** and enable it (toggle on). 3. A **Real client IP** segmented control appears. Select **Cloudflare CDN**. - This writes `CF-Connecting-IP` into `sockopt.trustedXForwardedFor` automatically. 4. Save and restart Xray (**Restart** in the panel, or `x-ui restart`). Alternatively, you can set `trustedXForwardedFor` manually 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 as `X-Forwarded-For` source addresses. **Transport restriction (confirmed in `frontend/src/pages/inbounds/form/transport/sockopt.tsx` line 15):** `trustedXForwardedFor` is 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 `sockopt` block to the Xray config at apply time. *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@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.

<!-- gh-comment-id:4777981748 --> @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.
Author
Owner

@DenMaxRus commented on GitHub (Jun 23, 2026):

@JackieWelles17 neirobot clearly lies here, because trustedXForwardedFor requires another header name, not ip range https://github.com/XTLS/Xray-core/pull/5331. Also, official doc states:

If left unset, the old behavior remains: as long as the request contains X-Forwarded-For, Xray reads it. https://xtls.github.io/en/config/transports/sockopt.html#sockoptobject

but for now i can't make it to work by removing trustedXForwardedFor field from json or even setting additional X-Real-IP header

UPD. Just adding X-Real-IP header and setting it in trustedXForwardedFor worked

grpc_set_header X-Real-IP       $remote_addr;
grpc_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
grpc_pass 127.0.0.1:12345;

UPD2. I checked again and if trustedXForwardedFor is fully removed from json, it does NOT behave like it is described in docs so...

<!-- gh-comment-id:4782293077 --> @DenMaxRus commented on GitHub (Jun 23, 2026): @JackieWelles17 neirobot clearly lies here, because `trustedXForwardedFor` requires another header name, not ip range https://github.com/XTLS/Xray-core/pull/5331. Also, official doc states: > If left unset, the old behavior remains: as long as the request contains X-Forwarded-For, Xray reads it. https://xtls.github.io/en/config/transports/sockopt.html#sockoptobject but for now i can't make it to work by removing `trustedXForwardedFor` field from json or even setting additional `X-Real-IP` header UPD. Just adding `X-Real-IP` header and setting it in `trustedXForwardedFor` worked ``` grpc_set_header X-Real-IP $remote_addr; grpc_set_header X-Forwarded-For $proxy_add_x_forwarded_for; grpc_pass 127.0.0.1:12345; ``` UPD2. I checked again and if `trustedXForwardedFor` is fully removed from json, it does NOT behave like it is described in docs so...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3839
No description provided.