Skip to content

Commit 642e529

Browse files
[Fundamentals] Add HTTP response headers section and rename page (#18945)
--------- Co-authored-by: Pedro Sousa <[email protected]>
1 parent f80770e commit 642e529

File tree

11 files changed

+99
-85
lines changed

11 files changed

+99
-85
lines changed

public/_redirects

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@
448448
/fundamentals/get-started/how-cloudflare-works/ /fundamentals/concepts/how-cloudflare-works/ 301
449449
/fundamentals/get-started/cloudflare-cookies/ /fundamentals/reference/policies-compliances/cloudflare-cookies/ 301
450450
/fundamentals/get-started/google-analytics/ /fundamentals/reference/google-analytics/ 301
451-
/fundamentals/get-started/http-request-headers/ /fundamentals/reference/http-request-headers/ 301
451+
/fundamentals/get-started/http-request-headers/ /fundamentals/reference/http-headers/ 301
452452
/fundamentals/get-started/network-ports/ /fundamentals/reference/network-ports/ 301
453453
/fundamentals/get-started/basic-tasks/improve-seo/ /fundamentals/basic-tasks/improve-seo/ 301
454454
/fundamentals/get-started/basic-tasks/allow-cloudflare-ip-addresses/ /fundamentals/concepts/cloudflare-ip-addresses/ 301
@@ -463,6 +463,7 @@
463463
/fundamentals/internet/ /fundamentals/concepts/the-internet/ 301
464464
/fundamentals/reference/developer-spotlight/ /developer-spotlight/ 301
465465
/fundamentals/reference/the-internet/ /fundamentals/concepts/the-internet/ 301
466+
/fundamentals/reference/http-request-headers/ /fundamentals/reference/http-headers/ 301
466467
/fundamentals/security/browser-integrity-check/ /waf/tools/browser-integrity-check/ 301
467468
/fundamentals/signed-exchanges/ /speed/optimization/other/signed-exchanges/ 301
468469
/fundamentals/signed-exchanges/amp-real-ulr/ /speed/optimization/other/amp-real-url/ 301

src/content/docs/data-localization/how-to/index.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ title: Configuration guides
33
pcx_content_type: navigation
44
sidebar:
55
order: 7
6-
76
---
87

9-
import { DirectoryListing } from "~/components"
8+
import { DirectoryListing } from "~/components";
109

1110
Learn how to use Cloudflare products with the Data Localization Suite.
1211

@@ -24,6 +23,6 @@ curl -X GET -I https://<HOSTNAME>/ 2>&1 | grep cf-ray
2423
curl -s https://<HOSTNAME>/cdn-cgi/trace | grep "colo="
2524
```
2625

27-
The first command will return a three-letter IATA code in the [CF-Ray](/fundamentals/reference/http-request-headers/#cf-ray) header, indicating the Cloudflare data center location of processing and/or TLS termination. The second command will directly return the three-letter IATA code.
26+
The first command will return a three-letter IATA code in the [Cf-Ray](/fundamentals/reference/http-headers/#cf-ray) header, indicating the Cloudflare data center location of processing and/or TLS termination. The second command will directly return the three-letter IATA code.
2827

2928
For example, when a hostname is configured to use the region European Union (EU), the three-letter IATA code will always return a data center inside of the EU.

src/content/docs/fundamentals/reference/cloudflare-ray-id.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
pcx_content_type: reference
33
title: Cloudflare Ray ID
4-
54
---
65

76
A **Cloudflare Ray ID** is an identifier given to every request that goes through Cloudflare.
@@ -10,7 +9,7 @@ Ray IDs are particularly useful when evaluating Security Events for patterns or
109

1110
:::caution
1211

13-
Ray IDs are not guaranteed to be unique for every request. In some situations, different requests may have the same Ray ID.
12+
Ray IDs are not guaranteed to be unique for every request. In some situations, different requests may have the same Ray ID.
1413
:::
1514

1615
## Look up Ray IDs
@@ -33,4 +32,4 @@ Enterprise customers can enable Ray ID as a field in their [Cloudflare Logs](/lo
3332

3433
### Server logs
3534

36-
For more details about sending Ray IDs to your server logs, refer to the [CF-Ray](/fundamentals/reference/http-request-headers/#cf-ray) header.
35+
For more details about sending Ray IDs to your server logs, refer to the [Cf-Ray](/fundamentals/reference/http-headers/#cf-ray) header.
Lines changed: 56 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,56 @@
11
---
22
pcx_content_type: reference
3-
title: Cloudflare HTTP request headers
3+
title: Cloudflare HTTP headers
44
---
55

66
import { Render } from "~/components";
77

8+
## Request headers
9+
810
Cloudflare passes all HTTP request headers to your origin web server and adds additional headers as specified below.
911

1012
:::note
11-
1213
Cloudflare may remove HTTP request headers with names considered invalid [according to NGINX](https://nginx.org/en/docs/http/ngx_http_core_module.html#ignore_invalid_headers) — for example, header names containing a `.` (dot) character.
1314
:::
1415

15-
## Accept-Encoding
16+
### Accept-Encoding
1617

1718
For incoming requests, the value of this header will always be set to `accept-encoding: br, gzip`. If the client set a different value, such as `accept-encoding: deflate`, it will be overwritten and the original value will be available in `request.cf.clientAcceptEncoding`.
1819

19-
## CF-Connecting-IP
20+
### CF-Connecting-IP
2021

2122
`CF-Connecting-IP` provides the client IP address connecting to Cloudflare to the origin web server.
2223
This header will only be sent on the traffic from Cloudflare's edge to your origin web server.
2324

24-
For guidance on logging your visitors original IP address, refer to [Restoring original visitor IPs](/support/troubleshooting/restoring-visitor-ips/restoring-original-visitor-ips/).
25+
For guidance on logging your visitor's original IP address, refer to [Restoring original visitor IPs](/support/troubleshooting/restoring-visitor-ips/restoring-original-visitor-ips/).
2526

2627
Alternatively, if you do not wish to receive the `CF-Connecting-IP` header or any HTTP header that may contain the visitor's IP address, [enable the **Remove visitor IP headers** Managed Transform](/rules/transform/managed-transforms/configure/).
2728

28-
### CF-Connecting-IP in Worker subrequests
29+
#### CF-Connecting-IP in Worker subrequests
2930

30-
In same-zone Worker subrequests, the value of `CF-Connecting-IP` reflects the value of `x-real-ip` (the clients IP). `x-real-ip` can be altered by the user in their Worker script.
31+
In same-zone Worker subrequests, the value of `CF-Connecting-IP` reflects the value of `x-real-ip` (the client's IP). `x-real-ip` can be altered by the user in their Worker script.
3132

3233
In cross-zone subrequests from one Cloudflare zone to another Cloudflare zone, the `CF-Connecting-IP` value will be set to the Worker client IP address `'2a06:98c0:3600::103'` for security reasons.
3334

3435
For Worker subrequests destined for a non-Cloudflare customer zone, the `CF-Connecting-IP` and `x-real-ip` headers will both reflect the client's IP address, with only the `x-real-ip` header able to be altered.
3536

3637
When no Worker subrequest is triggered, `cf-connecting-ip` reflects the client's IP address and the `x-real-ip` header is stripped.
3738

38-
## CF-Connecting-IPv6
39+
### CF-Connecting-IPv6
3940

4041
Cloudflare provides [free IPv6 support](/network/ipv6-compatibility/) to all domains without requiring additional configuration or hardware. To support migrating to IPv6, Cloudflare's [Pseudo IPv4](/network/pseudo-ipv4/) provides an IPv6 to IPv4 translation service for all Cloudflare domains.
4142

4243
<Render file="pseudo-ipv4-warning" /> <br />
4344

44-
## CF-EW-Via
45+
### CF-EW-Via
4546

4647
This header is used for loop detection, similar to the `CDN-Loop` [header](https://blog.cloudflare.com/preventing-request-loops-using-cdn-loop/).
4748

48-
## CF-Pseudo-IPv4
49+
### CF-Pseudo-IPv4
4950

5051
If [Pseudo IPv4](/network/pseudo-ipv4/) is set to `Add Header` - Cloudflare automatically adds the `CF-Pseudo-IPv4` header with a Class E IPv4 address hashed from the original IPv6 address.
5152

52-
## True-Client-IP (Enterprise plan only)
53+
### True-Client-IP (Enterprise plan only)
5354

5455
`True-Client-IP` provides the original client IP address to the origin web server. `True-Client-IP` is only available on an Enterprise plan. In the example below, `203.0.113.1` is the original visitor IP address. For example: `True-Client-IP: 203.0.113.1`
5556

@@ -60,12 +61,10 @@ To add a `True-Client-IP` HTTP header to requests, [enable the **Add "True-Clien
6061
Alternatively, if you do not wish to receive the `True-Client-IP` header or any HTTP header that may contain the visitor's IP address, [enable the **Remove visitor IP headers** Managed Transform](/rules/transform/managed-transforms/configure/).
6162

6263
:::caution
63-
6464
If you are using Cloudflare in a stacked CDN and authenticating HTTP requests based on the IP address value in the `True-Client-IP` header, you must add a `True-Client-IP` header to your requests. If you do not add this header, its value can be spoofed to any value.
65-
6665
:::
6766

68-
## X-Forwarded-For
67+
### X-Forwarded-For
6968

7069
`X-Forwarded-For` maintains proxy server and original visitor IP addresses. If there was no existing `X-Forwarded-For`header in the request sent to Cloudflare, `X-Forwarded-For` has an identical value to the `CF-Connecting-IP` header.
7170

@@ -76,28 +75,26 @@ If, on the other hand, an `X-Forwarded-For` header was already present in the re
7675
If you do not wish to receive the visitor's IP address in the `X-Forwarded-For` header, or any HTTP header that may contain the visitor's IP address, [enable the **Remove visitor IP headers** Managed Transform](/rules/transform/managed-transforms/configure/).
7776

7877
:::note
79-
8078
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`. `CF-Connecting-IP` and `True-Client-IP` both have a consistent format containing only one IP address.
81-
8279
:::
8380

84-
## X-Forwarded-Proto
81+
### X-Forwarded-Proto
8582

8683
`X-Forwarded-Proto` is used to identify the protocol (HTTP or HTTPS) that Cloudflare uses to connect to origin web server. By default, it is `http`. Certain [encryption mode](/ssl/origin-configuration/ssl-modes/) may change this header to `https` if the connection is encrypted.
8784

8885
For incoming requests, the value of this header will be set to the protocol the client used (`http` or `https`). If the client set a different value, it will be overwritten.
8986

90-
## CF-RAY
87+
### Cf-Ray
9188

92-
The `CF-ray` header (otherwise known as a [Ray ID](/fundamentals/reference/cloudflare-ray-id/)) is a hashed value that encodes information about the data center and the visitors request. For example: `CF-RAY: 230b030023ae2822-SJC`.
89+
The `Cf-Ray` header (otherwise known as a [Ray ID](/fundamentals/reference/cloudflare-ray-id/)) is a hashed value that encodes information about the data center and the visitor's request. For example: `Cf-Ray: 230b030023ae2822-SJC`.
9390

94-
Add the [`CF-Ray` header to your origin web server logs](/support/troubleshooting/general-troubleshooting/gathering-information-for-troubleshooting-sites/#add-the-cf-ray-header-to-your-logs) to match requests proxied to Cloudflare to requests in your server logs.
91+
Add the [`Cf-Ray` header to your origin web server logs](/support/troubleshooting/general-troubleshooting/gathering-information-for-troubleshooting-sites/#add-the-cf-ray-header-to-your-logs) to match requests proxied to Cloudflare to requests in your server logs.
9592

9693
Enterprise customers can also see all requests via [Cloudflare Logs](/logs/).
9794

98-
## CF-IPCountry
95+
### CF-IPCountry
9996

100-
The `CF-IPCountry` header contains a two-character country code of the originating visitors country.
97+
The `CF-IPCountry` header contains a two-character country code of the originating visitor's country.
10198

10299
Besides the [ISO-3166-1 alpha-2 codes](https://www.iso.org/iso-3166-country-codes.html), Cloudflare uses the following special country codes:
103100

@@ -107,44 +104,67 @@ Besides the [ISO-3166-1 alpha-2 codes](https://www.iso.org/iso-3166-country-code
107104
To add this header to requests, along with other HTTP headers with location information for the visitor's IP address, [enable the **Add visitor location headers** Managed Transform](/rules/transform/managed-transforms/configure/).
108105

109106
:::note
110-
111107
The `CF-IPCountry` header is removed from requests made from a Worker to an origin that is not proxied behind Cloudflare.
112-
113108
:::
114109

115-
## CF-Visitor
110+
### CF-Visitor
116111

117-
Currently, this header is a JSON object, containing only one key called scheme. The header will be either HTTP or HTTPS, and it is only relevant if you need to enable Flexible SSL in your Cloudflare settings. For example: `CF-Visitor: { \"scheme\":\"https\"}`.
112+
Currently, this header is a JSON object, containing only one key called `scheme`. The header will be either HTTP or HTTPS, and it is only relevant if you need to enable Flexible SSL in your Cloudflare settings. For example: `CF-Visitor: { \"scheme\":\"https\"}`.
118113

119-
## CDN-Loop
114+
### CDN-Loop
120115

121-
`CDN-Loop` allows Cloudflare to specify how many times a request can enter Cloudflare's network before it is blocked as a looping request. For example: `CDN-Loop: cloudflare`
116+
`CDN-Loop` allows Cloudflare to specify how many times a request can enter Cloudflare's network before it is blocked as a looping request. For example: `CDN-Loop: cloudflare`.
122117

123-
## CF-Worker
118+
### CF-Worker
124119

125-
The `CF-Worker` request header is added to an edge Worker subrequest that identifies the host that spawned the subrequest. This is useful when you want to protect yourself against cross-zone worker subrequests. For example: `CF-Worker: example.com`.
120+
The `CF-Worker` request header is added to an edge Worker subrequest that identifies the host that spawned the subrequest. This is useful when you want to protect yourself against cross-zone Worker subrequests. For example: `CF-Worker: example.com`.
126121

127122
You can add `CF-Worker` header on server logs similar to the way you add the [`CF-RAY`](/support/troubleshooting/general-troubleshooting/gathering-information-for-troubleshooting-sites/#add-the-cf-ray-header-to-your-logs) header. To do that, add `$http_cf_worker` in the log format file: `log_format cf_custom "CF-Worker:$http_cf_worker"'`
128123

129124
`CF-Worker` is added to all Worker subrequests sent via `fetch()`. It is set to the name of the zone which owns the Worker making the subrequest. For example, a Worker script on route for `foo.example.com/*` from `example.com` will have all subrequests with the header:
130125

131-
`CF-Worker`: `example.com`
126+
```txt
127+
CF-Worker: example.com
128+
```
132129

133130
The intended purpose of this header is to provide a means for recipients (for example, origins, load balancers, other Workers) to recognize, filter, and route traffic generated by Workers on specific zones.
134131

135132
:::note
136-
137-
When configuring WAF custom rules, do not match on this header. These rules are applied before Cloudflare adds the `CF-Worker` header. Instead, use the [`cf.worker.upstream_zone`](/ruleset-engine/rules-language/fields/reference/cf.worker.upstream_zone/) dynamic field, which contains the same value and exists for the same purpose.
138-
133+
When configuring WAF custom rules, do not match on this header. These rules are applied before Cloudflare adds the `CF-Worker` header. Instead, use the [`cf.worker.upstream_zone`](/ruleset-engine/rules-language/fields/reference/cf.worker.upstream_zone/) field, which contains the same value and exists for the same purpose.
139134
:::
140135

141-
## Connection
136+
### Connection
142137

143138
For incoming requests, the value of this header will always be set to `Keep-Alive`. If the client set a different value, such as `close`, it will be overwritten. Note that is also the case when the client uses HTTP/2 or HTTP/3 to connect.
144139

145-
## Considerations for Spectrum
140+
### Considerations for Spectrum
146141

147142
When using Spectrum with a TCP application, these headers are not visible at the origin as they are HTTP headers. If you wish to utilize these in your application, there are two options:
148143

149144
- Use an HTTP or HTTPS Spectrum app instead of TCP
150145
- Use the [Proxy Protocol feature](/spectrum/how-to/enable-proxy-protocol/)
146+
147+
## Response headers
148+
149+
Cloudflare will remove some HTTP headers from the response sent back to the visitor and add some Cloudflare-specific HTTP headers.
150+
151+
### Removed response headers
152+
153+
Cloudflare passes all HTTP headers in the response from the origin server back to the visitor with the exception of the following headers:
154+
155+
- `X-Accel-Buffering`
156+
- `X-Accel-Charset`
157+
- `X-Accel-Limit-Rate`
158+
- `X-Accel-Redirect`
159+
160+
### Added response headers
161+
162+
Cloudflare adds the HTTP headers specified below to the response sent to the visitor.
163+
164+
#### Cf-Ray
165+
166+
The `Cf-Ray` value returned to the visitor will be the same `Cf-Ray` value that was sent to the origin server.
167+
168+
#### Cf-Cache-Status
169+
170+
A list of all possible `Cf-Cache-Status` values is contained in [Cloudflare cache responses](/cache/concepts/cache-responses/).

src/content/docs/network/ip-geolocation.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: IP geolocation
66

77
import { FeatureTable, TabItem, Tabs } from "~/components";
88

9-
IP geolocation adds the [`CF-IPCountry` header](/fundamentals/reference/http-request-headers/#cf-ipcountry) to all requests to your origin server.
9+
IP geolocation adds the [`CF-IPCountry` header](/fundamentals/reference/http-headers/#cf-ipcountry) to all requests to your origin server.
1010

1111
Cloudflare automatically updates its IP geolocation database using MaxMind and other data sources, typically twice a week.
1212

@@ -36,7 +36,7 @@ To enable **IP Geolocation** with the API, send a [`PATCH`](/api/resources/zones
3636

3737
:::note
3838

39-
In order to use this data, you will need to then retrieve it from the [`CF-IPCountry` header](/fundamentals/reference/http-request-headers/#cf-ipcountry).
39+
In order to use this data, you will need to then retrieve it from the [`CF-IPCountry` header](/fundamentals/reference/http-headers/#cf-ipcountry).
4040

4141
:::
4242

src/content/docs/network/true-client-ip-header.mdx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
pcx_content_type: troubleshooting
33
source: https://support.cloudflare.com/hc/en-us/articles/206776727-Understanding-the-True-Client-IP-Header
44
title: Understanding the True-Client-IP Header
5-
65
---
76

8-
import { FeatureTable } from "~/components"
7+
import { FeatureTable } from "~/components";
98

10-
Enabling the True-Client-IP Header adds the [`True-Client-IP` header](/fundamentals/reference/http-request-headers/#true-client-ip-enterprise-plan-only) to all requests to your origin server, which includes the end users IP address.
9+
Enabling the True-Client-IP Header adds the [`True-Client-IP` header](/fundamentals/reference/http-headers/#true-client-ip-enterprise-plan-only) to all requests to your origin server, which includes the end user's IP address.
1110

1211
## Availability
1312

@@ -18,17 +17,13 @@ Enabling the True-Client-IP Header adds the [`True-Client-IP` header](/fundament
1817
The recommended procedure to access client IP information is to [enable the **Add "True-Client-IP" header** Managed Transform](/rules/transform/managed-transforms/reference/#add-true-client-ip-header).
1918

2019
:::note
21-
22-
23-
In order to use this data, you will need to then retrieve it from the [`True-Client-IP` header](/fundamentals/reference/http-request-headers/#cf-ipcountry).
24-
25-
20+
To use this data, you will need to then retrieve it from the [`True-Client-IP` header](/fundamentals/reference/http-headers/#cf-ipcountry).
2621
:::
2722

2823
## Additional resources
2924

3025
For additional guidance on using True-Client-IP Header with Cloudflare, refer to the following resources:
3126

32-
* [Available Managed Transforms](/rules/transform/managed-transforms/reference/#add-true-client-ip-header)
33-
* [HTTP request headers](/fundamentals/reference/http-request-headers/#true-client-ip-enterprise-plan-only)
34-
* [Restoring original visitor IPs](/support/troubleshooting/restoring-visitor-ips/restoring-original-visitor-ips/)
27+
- [Available Managed Transforms](/rules/transform/managed-transforms/reference/#add-true-client-ip-header)
28+
- [Cloudflare HTTP headers](/fundamentals/reference/http-headers/#true-client-ip-enterprise-plan-only)
29+
- [Restoring original visitor IPs](/support/troubleshooting/restoring-visitor-ips/restoring-original-visitor-ips/)

0 commit comments

Comments
 (0)