Cloudflare Docs
Rules
Visit Rules on GitHub
Set theme to dark (⇧+D)

Response header modification examples

The following examples illustrate how to perform response header modifications with Transform Rules:

Add an HTTP response header with a static value

The following HTTP Response Header Modification Rule adds a header named X-Source with a static value (Cloudflare) to the response:

Text in Expression Editor:

starts_with(http.request.uri.path, "/en/")

Selected operation under Modify response header: Set static

Header name: X-Source

Value: Cloudflare

Add an HTTP response header with the current bot score

The following HTTP Response Header Modification Rule adds a header named X-Bot-Score with the current bot score to the response:

Text in Expression Editor:

starts_with(http.request.uri.path, "/en/")

Selected operation under Modify response header: Set dynamic

Header name: X-Bot-Score

Value: to_string(cf.bot_management.score)

Remove an HTTP response header

The following HTTP Response Header Modification Rule removes the cf-connecting-ip header from the response:

Text in Expression Editor:

starts_with(http.request.uri.path, "/private/")

Selected operation under Modify response header: Remove

Header name: cf-connecting-ip