---
title: "CF-Connecting-IP: what the Cloudflare header means"
url: https://proxy.wiki/glossary/cf-connecting-ip/
type: Glossary Term
author: "proxy.wiki editorial"
published: 2026-10-21
updated: 2026-10-21
site: proxy.wiki
topics: ["Proxy fundamentals"]
license: CC BY 4.0; quote freely with attribution to https://proxy.wiki/
---

# CF-Connecting-IP: what the Cloudflare header means

> CF-Connecting-IP carries a visitor address from Cloudflare to an origin. Learn the trust boundary, Nginx setup and spoofing test.

## Key takeaways

- CF-Connecting-IP is added on Cloudflare edge-to-origin traffic.
- A direct client can forge the header if the origin is exposed.
- Allowlist Cloudflare ranges before using it as a client address.

**`CF-Connecting-IP` is a Cloudflare request header that carries the visitor address from Cloudflare’s edge to the origin.** It is useful when the origin would otherwise log a Cloudflare edge address, but it is trustworthy only on a request that your origin has already established came from Cloudflare.

## What Cloudflare sends

Cloudflare describes itself as a reverse proxy. The client connects to an edge, and the edge opens a separate connection to the origin. Cloudflare’s documentation says the header is sent only on traffic from its edge to the origin and contains the client IP that connected to Cloudflare. That is different from a browser adding the header itself. A direct request to an exposed origin can add any ordinary HTTP header, including this one.

The value is one address, which is simpler to consume than a proxy chain. If Pseudo IPv4 is configured to overwrite headers, Cloudflare can put a generated IPv4 value in `CF-Connecting-IP` and preserve the real IPv6 address in `CF-Connecting-IPv6`. Check that setting before treating the value as the original address.

Worker subrequests need a separate trust check. Cloudflare documents that a same-zone Worker can alter `x-real-ip`, which becomes `CF-Connecting-IP` for that subrequest. Use an authenticated origin mechanism for zone identity, or treat Worker-provided values as Worker-controlled.

## A local capture and the trust boundary

Our local Python 3.15.0 echo server received a manually supplied header from curl 8.7.1. This is intentionally a direct request, so it demonstrates why the header must not be trusted from every peer:

```
$ curl -sS http://127.0.0.1:57011/ -H 'CF-Connecting-IP: 203.0.113.24'
REMOTE_ADDR=127.0.0.1
CF-Connecting-IP=203.0.113.24
X-Real-IP=<missing>
exit=0
```

The server saw the real TCP peer as `127.0.0.1` and the claimed visitor as `203.0.113.24`. That is expected HTTP behaviour. In production, restrict the origin to Cloudflare’s published IP ranges at the firewall or load balancer, then accept the header only from those ranges. Cloudflare’s own restoration guide repeats this requirement for Nginx and other servers.

## Using it in an origin

Nginx’s real IP module can replace its client address after you define trusted senders. The module is not built by default, so check `nginx -V` before using the directives:

```
# Example documentation range only. Use Cloudflare's current ranges.
set_real_ip_from 192.0.2.0/24;
real_ip_header CF-Connecting-IP;
real_ip_recursive off;
```

Do not copy the documentation range into a live firewall. Fetch the current list from Cloudflare, keep it under change control, and test a request from an allowed and a disallowed source. If another trusted proxy sits between Cloudflare and Nginx, model that hop explicitly instead of accepting the header from the whole internet. The [reverse proxy reference](/glossary/reverse-proxy/) explains why two connections exist.

| Request path | Header value | Safe interpretation |
| --- | --- | --- |
| Cloudflare edge to an origin that allows only Cloudflare IPs | Cloudflare’s client address | Use after the source-range check and any IPv6/Pseudo IPv4 check |
| Direct request to an exposed origin | Whatever the caller typed | Ignore it for identity and access control |
| Cloudflare Worker subrequest | Worker and zone rules apply | Read the Worker-specific Cloudflare documentation |
| Cloudflare Pseudo IPv4 overwrite | Generated IPv4 value | Also inspect CF-Connecting-IPv6 |

## Logging and application use

Keep both the transport peer and the selected client address in logs. A pair such as `peer=172.64.0.1 client=203.0.113.24` lets you diagnose a bad allowlist or a forged direct request. Do not use the header alone to authorize an administrator, issue a password reset, or apply a ban. IP addresses are not identity, and even a correctly restored address can be shared or rotated.

Cloudflare recommends this single-value header over reconstructing the first value in `X-Forwarded-For`. Compare the two in the site’s [X-Forwarded-For reference](/glossary/x-forwarded-for/), and see what ordinary clients send in the [default request headers study](/research/default-request-headers/). When debugging a rejection, the [status-code guide](/guides/403-vs-407-vs-429/) separates an edge decision from a proxy authentication failure.

## Frequently asked questions

### Can a visitor spoof CF-Connecting-IP?

They can send any value to an exposed origin. Restrict origin traffic to Cloudflare's current IP ranges, then process the header.

### Is CF-Connecting-IP the same as X-Forwarded-For?

No. CF-Connecting-IP is Cloudflare's single client value. X-Forwarded-For can contain a proxy chain and needs a hop-by-hop trust policy.

### Why is the value an IPv4 address when the visitor used IPv6?

Cloudflare Pseudo IPv4 may overwrite the header. Check CF-Connecting-IPv6 and the zone setting before geolocating the value.

## Sources

1. [Cloudflare: HTTP headers](https://developers.cloudflare.com/fundamentals/reference/http-headers/)
2. [Cloudflare: Restoring original visitor IPs](https://developers.cloudflare.com/support/troubleshooting/restoring-visitor-ips/restoring-original-visitor-ips/)
3. [Nginx: ngx_http_realip_module](https://nginx.org/en/docs/http/ngx_http_realip_module.html)
4. [RFC 7239: Forwarded HTTP Extension](https://www.rfc-editor.org/rfc/rfc7239.html)
