Use Response Header Transform Rules to manipulate the headers of HTTP responses sent to website visitors.
flowchart LR accTitle: Header modifications diagram accDescr: Header transform rules can change the headers sent to your origin server (request header modifications) or sent your your website visitors (response header modifications). A[Visitor] B((Cloudflare)) C[(Origin server)] A -.-> B -. "Includes request<br> header modifications" .-> C C -.-> B == "Includes response<br> header modifications" ==> A style A stroke-width: 2px style B stroke: orange,fill: orange,color: black linkStyle 0,1,2 stroke-width: 1px linkStyle 3 stroke-width: 3px
To modify HTTP headers in the request sent to your origin server, refer to Request Header Transform Rules.
Through Response Header Transform Rules you can:
You can create a response header transform rule in the dashboard, via API, or using Terraform.
For more complex response header modifications, consider using Snippets.
The response header values are calculated using the field values from the corresponding HTTP request. For example, the value of ip.src.country
will be the country of the website visitor, not the origin where the response was sent from.
You cannot modify or remove HTTP response headers whose name starts with cf-
or x-cf-
.
You cannot modify the value of certain headers such as server
, eh-cache-tag
, or eh-cdn-cache-control
.
Currently you cannot reference IP lists in expressions of Response Header Transform Rules.
The HTTP response header removal operation will remove all response headers with the provided name.
If you change the value of an existing HTTP response header using an expression that evaluates to an empty string (""
) or an undefined value, the HTTP response header is removed.
Currently, there is a limited number of HTTP response headers that you cannot change. Cloudflare may remove restrictions for some of these HTTP response headers when presented with valid use cases. Create a post in the community â for consideration.
Response Header Transform Rules will also apply to default Cloudflare error pages and Custom Errors.
Modifying cache-control
, CDN-Cache-Control
, or Cloudflare-CDN-Cache-Control
headers will not change the way Cloudflare caches an object. Instead, you should create a Cache Rule.
To add a set-cookie
header to the response, make sure you use one of the Add static/Add dynamic operations instead of Set static/Set dynamic. Using one of the Set operations will remove any set-cookie
headers already in the response, including those added by other Cloudflare products such as Bot Management.
When troubleshooting Response Header Transform Rules, use Cloudflare Trace to determine if a rule is triggering for a specific URL.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4