Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ Cloudflare does not:

If you require the CSP headers to be changed or added, you can change them using some Cloudflare products:

- If your website is [proxied](/dns/proxy-status/) through Cloudflare, you can use a [Response Header Modification rule](/rules/transform/response-header-modification/) to replace or add CSP headers.
- If your website is [proxied](/dns/proxy-status/) through Cloudflare, you can use a [response header transform rule](/rules/transform/response-header-modification/) to replace or add CSP headers.
- If your website is hosted using [Cloudflare Pages](/pages/), you can set a [`_headers file`](/pages/configuration/headers/) to modify or add CSP headers.

### Product requirements

To use certain Cloudflare features, however, you may need to update the headers in your CSP:

| Feature(s) | Updated headers |
| ----------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| [Rocket Loader](/speed/optimization/content/rocket-loader/), [Mirage](/speed/optimization/images/mirage/) | `script-src 'self' ajax.cloudflare.com;` |
| [Cloudflare Apps](https://cloudflareapps.com/apps/developer/docs/getting-started), [Scrape Shield](/waf/tools/scrape-shield/) | `script-src 'self' 'unsafe-inline'` |
| [Web Analytics](/web-analytics/) | `script-src static.cloudflareinsights.com; connect-src cloudflareinsights.com` |
| Feature(s) | Updated headers |
| ----------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| [Rocket Loader](/speed/optimization/content/rocket-loader/), [Mirage](/speed/optimization/images/mirage/) | `script-src 'self' ajax.cloudflare.com;` |
| [Cloudflare Apps](https://cloudflareapps.com/apps/developer/docs/getting-started), [Scrape Shield](/waf/tools/scrape-shield/) | `script-src 'self' 'unsafe-inline'` |
| [Web Analytics](/web-analytics/) | `script-src static.cloudflareinsights.com; connect-src cloudflareinsights.com` |
| [Bot products](/bots/) | Refer to [JavaScript detections and CSPs](/bots/additional-configurations/javascript-detections/#if-you-have-a-content-security-policy-csp). |
| [Page Shield](/page-shield/) | Refer to [Page Shield CSP Header format](/page-shield/reference/csp-header/). |
| [Zaraz](/zaraz/) | No updates required ([details](https://blog.cloudflare.com/cloudflare-zaraz-supports-csp/)). |
| [Turnstile](/turnstile/) | Refer to [Turnstile CSP](/turnstile/reference/content-security-policy/). |
| [Page Shield](/page-shield/) | Refer to [Page Shield CSP Header format](/page-shield/reference/csp-header/). |
| [Zaraz](/zaraz/) | No updates required ([details](https://blog.cloudflare.com/cloudflare-zaraz-supports-csp/)). |
| [Turnstile](/turnstile/) | Refer to [Turnstile CSP](/turnstile/reference/content-security-policy/). |
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ https://www.mywebsite.com/cdn-cgi/image/width=80,quality=75/uploads/image.jpg

- [Image Resizing Documentation](/images/transform-images/)
- [Cloudflare R2 Developer Docs](/r2/)
- [Rewrite URL rules](/rules/transform/url-rewrite/)
- [URL Rewrite Rules](/rules/transform/url-rewrite/)
- [Serverless image content management platform](/reference-architecture/diagrams/serverless/serverless-image-content-management/)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To route requests to `/images` on your domain to an AWS S3 bucket:
4. Enter the bucket URL. You can structure the URL in two ways:
- **Subdomain-style URL**: Set the hostname to `<BUCKET_NAME>.s3.amazonaws.com`. In this case, your files should be organized in the root of the bucket, meaning the URI path will map directly to the file. For example, `https://<YOUR_HOSTNAME>/images/file.jpg` will map to `https://<BUCKET_NAME>.s3.amazonaws.com/images/file.jpg`.
- **URI path-style URL**: Set the hostname to `s3.amazonaws.com`. Here, your bucket must include a folder named `images`, and files should be placed inside this folder. The URI path will then include the bucket name, like `https://<YOUR_HOSTNAME>/<BUCKET_NAME>/images/file.jpg` mapping to `https://s3.amazonaws.com/<BUCKET_NAME>/images/file.jpg`.
5. _(Optional)_ Use the [Rewrite URL](/rules/transform/url-rewrite/) feature of [Transform Rules](/rules/transform/) to adjust the URL structure. For example, you can [create a URL rewrite](/rules/transform/url-rewrite/create-dashboard/) that changes `/images` to `/<BUCKET_NAME>/images` to match the URI path-style URL structure.
5. _(Optional)_ Use [URL Rewrite Rules](/rules/transform/url-rewrite/) to adjust the URL structure. For example, you can [create a URL rewrite](/rules/transform/url-rewrite/create-dashboard/) that changes `/images` to `/<BUCKET_NAME>/images` to match the URI path-style URL structure.
6. Select **Next** and enter a descriptive name like `Route images to S3` in **Cloud Connector name**.
7. Under **If**, select **Custom filter expression** and enter the following expression:<br />
`http.request.full_uri wildcard "http*://<YOUR_HOSTNAME>/images/*"`<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To route requests from visitors in the European Union to a Google Cloud Storage
4. Enter the bucket URL. You can structure the URL in two ways:
- **Subdomain-style URL**: For `<BUCKET_NAME>.storage.googleapis.com`, your files should be organized in the root of the bucket. For example, `https://<YOUR_HOSTNAME>/index.html` will map to `https://<BUCKET_NAME>.storage.googleapis.com/index.html`.
- **URI path-style URL**: If you set the hostname to `storage.googleapis.com`, your bucket must include folders corresponding to the intended URI paths. For example, if you want `https://<YOUR_HOSTNAME>/eu/index.html` to map to a file in your bucket, the file should be placed at `https://storage.googleapis.com/<BUCKET_NAME>/eu/index.html`.
5. _(Optional)_ Use the [Rewrite URL](/rules/transform/url-rewrite/) feature of [Transform Rules](/rules/transform/) to adjust the URL structure. For example, you can [create a URL rewrite](/rules/transform/url-rewrite/create-dashboard/) that changes `/eu` to `/<BUCKET_NAME>` to match the URI path-style URL structure.
5. _(Optional)_ Use [URL Rewrite Rules](/rules/transform/url-rewrite/) to adjust the URL structure. For example, you can [create a URL rewrite](/rules/transform/url-rewrite/create-dashboard/) that changes `/eu` to `/<BUCKET_NAME>` to match the URI path-style URL structure.
6. Select **Next** and enter a descriptive name like `Route EU visitors to GCP` in **Cloud Connector name**.
7. Under **If**, select **Custom filter expression** and enter the following expression:
`(ip.src.is_in_european_union)`<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ To serve static assets from an Azure Blob Storage container:
3. Select **Microsoft Azure - Blob Storage** as your [cloud provider](/rules/cloud-connector/providers/).
4. Enter the bucket URL. Use the following URL structure:
- **Subdomain-style URL**: Set the hostname to `<BUCKET_NAME>.blob.core.windows.net`. In this case, your bucket should include a folder named `static-assets`, and files should be placed inside this folder. For example, `https://<YOUR_HOSTNAME>/static-assets/style.css` will map to `https://<BUCKET_NAME>.blob.core.windows.net/static-assets/style.css`.
5. _(Optional)_ Use the [Rewrite URL](/rules/transform/url-rewrite/) feature of [Transform Rules](/rules/transform/) to adjust the URL structure. For example, you can [create a URL rewrite](/rules/transform/url-rewrite/create-dashboard/) that changes `/static-assets` to `/my-pages-project/static-assets` to match the file structure of your object storage bucket.
5. _(Optional)_ Use [URL Rewrite Rules](/rules/transform/url-rewrite/) to adjust the URL structure. For example, you can [create a URL rewrite](/rules/transform/url-rewrite/create-dashboard/) that changes `/static-assets` to `/my-pages-project/static-assets` to match the file structure of your object storage bucket.
6. Click **Next** and enter a descriptive name like `Serve static assets from Azure` in **Cloud Connector name**.
7. Under **If**, select **Custom filter expression** and enter the following expression:
`http.request.full_uri wildcard "http*://<YOUR_HOSTNAME>/static-assets/*"`<br />
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/rules/compression-rules/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ The following fields are commonly used in expressions of compression rules:

<Render
file="troubleshoot-rules-with-trace"
params={{ rulesFeatureName: "compression rules" }}
params={{ rulesFeatureName: "Compression Rules" }}
/>
2 changes: 1 addition & 1 deletion src/content/docs/rules/configuration-rules/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ The number of available configuration rules varies according to your Cloudflare

<Render
file="troubleshoot-rules-with-trace"
params={{ rulesFeatureName: "configuration rules" }}
params={{ rulesFeatureName: "Configuration Rules" }}
/>
2 changes: 1 addition & 1 deletion src/content/docs/rules/custom-errors/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ When a custom error rule is triggered, Cloudflare will replace the body with the

Cloudflare will keep any existing HTTP response headers except for `Content-Type` and `Content-Length`.

Additionally, you can configure [HTTP response header modification rules](/rules/transform/response-header-modification/) for error responses to add, change, or remove HTTP headers from the response.
Additionally, you can configure [Response Header Transform Rules](/rules/transform/response-header-modification/) for error responses to add, change, or remove HTTP headers from the response.

## Availability

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ Use a URL rewrite to remove the `/blog` segment from the URL path.

6. In **Then rewrite the path and/or query**, enter the following values under **Path**:

| Target path | Rewrite to |
| ----------- | ---------- |
| `blog/*` | `${1}` |
| Target path | Rewrite to |
| -------------- | ------------ |
| [`/`] `blog/*` | [`/`] `${1}` |

7. Select **Deploy**.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ Use a URL rewrite to remove the `/images` segment from the URL path. Cloudflare

6. In **Then rewrite the path and/or query**, enter the following values under **Path**:

| Target path | Rewrite to |
| ----------- | ---------- |
| `images/*` | `${1}` |
| Target path | Rewrite to |
| ---------------- | ------------ |
| [`/`] `images/*` | [`/`] `${1}` |

7. Select **Deploy**.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ becomes a **filter expression** such as:

</Example>

[Single Redirects](/rules/url-forwarding/single-redirects/create-dashboard/) and [Rewrite URL](/rules/transform/url-rewrite/create-dashboard/) rules also offer a simplified view called **Wildcard pattern**, allowing you to specify URL patterns (`http*://example.com/*/downloads/*.txt*`) without specifying the full filter expression (`http.request.full_uri wildcard "http*://example.com/*/downloads/*.txt*"`).
[Single Redirects](/rules/url-forwarding/single-redirects/create-dashboard/) and [URL Rewrite Rules](/rules/transform/url-rewrite/create-dashboard/) also offer a simplified view called **Wildcard pattern**, allowing you to specify URL patterns (`http*://example.com/*/downloads/*.txt*`) without specifying the full filter expression (`http.request.full_uri wildcard "http*://example.com/*/downloads/*.txt*"`).

### Important considerations

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
---
pcx_content_type: example
summary: Create a request header modification rule (part of Transform Rules) to
add a `X-Bot-Score` HTTP header to the request with the current bot score.
summary: Create a request header transform rule to add a `X-Bot-Score` HTTP header to the request with the current bot score.
products:
- Transform Rules
operation:
- Request modification
title: Add a request header with the current bot score
description: Create a request header modification rule (part of Transform Rules)
to add a `X-Bot-Score` HTTP header to the request with the current bot score.
description: Create a request header transform rule to add a `X-Bot-Score` HTTP header to the request with the current bot score.
---

import { Example } from "~/components";

The following HTTP request header modification rule adds a header named `X-Bot-Score` with the current bot score to the request:
The following request header transform rule adds a header named `X-Bot-Score` with the current bot score to the HTTP request:

<Example>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
pcx_content_type: example
summary: Create a request header modification rule (part of Transform Rules) to
add an `X-Source` HTTP header to the request with a static value
summary:
Create a request header transform rule to add an `X-Source` HTTP header to the request with a static value
(`Cloudflare`).
products:
- Transform Rules
operation:
- Request modification
title: Add request header with a static value
description: Create a request header modification rule (part of Transform Rules)
to add an `X-Source` HTTP header to the request with a static value
description:
Create a request header transform rule to add an `X-Source` HTTP header to the request with a static value
(`Cloudflare`).
---

import { Example } from "~/components";

The following HTTP request header modification rule adds a header named `X-Source` with a static value (`Cloudflare`) to the request:
The following request header transform rule adds a header named `X-Source` with a static value (`Cloudflare`) to the HTTP request:

<Example>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
pcx_content_type: example
summary: Create a response header modification rule (part of Transform Rules) to
add a `set-cookie` HTTP header to the response with a static value
summary:
Create a response header transform rule to add a `set-cookie` HTTP header to the response with a static value
(`cookiename=value`).
products:
- Transform Rules
operation:
- Response modification
title: Add a response header with a static value
description: Create a response header modification rule (part of Transform
Rules) to add a `set-cookie` HTTP header to the response with a static value
description:
Create a response header transform rule to add a `set-cookie` HTTP header to the response with a static value
(`cookiename=value`).
---

import { Example } from "~/components";

The following HTTP response header modification rule adds a header named `set-cookie` with a static value (`cookiename=value`) to the response:
The following response header transform rule adds a header named `set-cookie` with a static value (`cookiename=value`) to the HTTP response:

<Example>

Expand All @@ -33,4 +33,4 @@ Selected operation under **Modify response header**: _Add_

</Example>

This rule would keep any existing `set-cookie` headers already present in the response.
This rule would keep any existing `set-cookie` headers already present in the HTTP response.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
pcx_content_type: example
summary: Create a rewrite URL rule (part of Transform Rules) to normalize encoded forward slashes (`%2F`) in the request path to standard slashes (`/`).
summary: Create a URL rewrite rule (part of Transform Rules) to normalize encoded forward slashes (`%2F`) in the request path to standard slashes (`/`).
products:
- Transform Rules
operation:
- Rewrite URL
title: Normalize encoded slashes in URL path
description: Create a rewrite URL rule (part of Transform Rules) to normalize encoded forward slashes (`%2F`) in the request path to standard slashes (`/`).
description: Create a URL rewrite rule (part of Transform Rules) to normalize encoded forward slashes (`%2F`) in the request path to standard slashes (`/`).
---

import { Example } from "~/components";
Expand All @@ -17,7 +17,7 @@ However, many origin servers **do** automatically decode `%2F` into `/` when pro

## How to normalize `%2F`

To normalize encoded forward slashes (`%2F`) to standard slashes (`/`) in the request path before [subsequent](/ruleset-engine/reference/phases-list/) rule evaluation, create a new rewrite URL rule and define a dynamic URL path rewrite using [`url_decode()`](/ruleset-engine/rules-language/functions/#url_decode) function:
To normalize encoded forward slashes (`%2F`) to standard slashes (`/`) in the request path before [subsequent](/ruleset-engine/reference/phases-list/) rule evaluation, create a new URL rewrite rule and define a dynamic URL path rewrite using [`url_decode()`](/ruleset-engine/rules-language/functions/#url_decode) function:

<Example>

Expand All @@ -27,12 +27,12 @@ Text in **Expression Editor**:
(lower(raw.http.request.full_uri) wildcard "*%2f*")
```

Text after **Path** > **Rewrite to...** > _Dynamic_:
Text after **Path** > **Rewrite to** > _Dynamic_:

```txt
url_decode(http.request.uri.path)
```

</Example>

This transformation ensures that `%2F` is always treated as `/` in the request path. This is particularly useful when setting up rules that depend on URL path matching, as it prevents discrepancies caused by differing normalization behaviors.
This transformation ensures that `%2F` is always treated as `/` in the request path. This is particularly useful when setting up rules that depend on URL path matching, as it prevents discrepancies caused by differing normalization behaviors.
Loading
Loading