Cloudflare supports X-Forwarded-For by default. It only “overrides” it by adding the actual connecting IP to the header, as the protocol requires, so if a client is using multiple compliant proxies, an X-Forwarded-For of 192.0.2.1, 192.0.2.2 will be changed to 192.0.2.3, 192.0.2.1, 192.0.2.2. In general, Cloudflare recommends against this header because of the format (from here):
To restore the original visitor IP address at your origin web server, Cloudflare recommends that your logs or applications look at CF-Connecting-IP or True-Client-IP , instead of X-Forwarded-For , since CF-Connecting-IP and True-Client-IP have a consistent format containing only one IP.
As for X-Real-Ip, you should be able to do it like so, using ip.src:
If it’s not changing then that’s the IP Cloudflare is setting. Here’s an echo service: https://httpbin.workers.works/headers, it lists the x-real-ip Cloudflare is sending as my real client IP address. If you really are seeing a Cloudflare proxy IP address then it might be getting overridden somewhere else in your stack.
If you mean True-Client-Ip this is specifically an enterprise-only feature. This is an extremely old, non-standard header that should be avoided at all costs.
Some Enterprise customers with legacy devices need True-Client-IP to avoid updating firewalls or load-balancers to read a custom header name.