Skip to content

Commit d1cefc3

Browse files
authored
[Rules] Use wildcard in URI scheme (#18181)
1 parent 0e842d7 commit d1cefc3

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

src/content/docs/rules/cloud-connector/create-dashboard.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ To configure a Cloud Connector rule in the dashboard:
2626

2727
6. Under **If**, select **Custom filter expression** and [enter an expression](/ruleset-engine/rules-language/expressions/edit-expressions/) to define the traffic that will be redirected to the bucket. For example:
2828

29-
- To route all requests under `https://example.com/images/*` you could enter the following expression:<br/>
30-
`http.request.full_uri wildcard "https://example.com/images/*"`
31-
- To route all requests under `https://images.example.com/*` you could enter the following expression:<br/>
32-
`http.request.full_uri wildcard "https://images.example.com/*"`
29+
- To route all requests matching `http*://example.com/images/*` (HTTPS and HTTP requests) you could enter the following expression:<br/>
30+
`http.request.full_uri wildcard "http*://example.com/images/*"`
31+
- To route all requests matching `http*://images.example.com/*` (HTTPS and HTTP requests) you could enter the following expression:<br/>
32+
`http.request.full_uri wildcard "http*://images.example.com/*"`
3333

3434
Alternatively, select **All incoming requests** to redirect all incoming traffic for your zone to the storage bucket you selected.
3535

src/content/docs/rules/cloud-connector/examples/route-images-to-s3.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ To route requests to `/images` on your domain to an AWS S3 bucket:
1616
- **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`.
1717
- **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`.
1818
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.
19-
6. Click **Next** and enter a descriptive name like "Route images to S3" in Cloud Connector name.
20-
7. Under **If**, select **Custom filter expression** and enter the following expression:
21-
`http.request.full_uri wildcard "https://<YOUR_HOSTNAME>/images/*"`<br />
19+
6. Click **Next** and enter a descriptive name like `Route images to S3` in **Cloud Connector name**.
20+
7. Under **If**, select **Custom filter expression** and enter the following expression:<br />
21+
`http.request.full_uri wildcard "http*://<YOUR_HOSTNAME>/images/*"`<br />
2222
Replace `<YOUR_HOSTNAME>` with desired hostname.
2323
8. Select **Deploy** to activate the rule.
2424

25-
This setup will route all traffic to `https://<YOUR_HOSTNAME>/images/*` directly to your S3 bucket. Make sure to replace `<YOUR_HOSTNAME>` with your actual hostname and adjust the example paths according to your setup.
25+
This setup will route all traffic matching `http*://<YOUR_HOSTNAME>/images/*` (HTTPS and HTTP requests) to your S3 bucket. Make sure to replace `<YOUR_HOSTNAME>` with your actual hostname and adjust the example paths according to your setup.

src/content/docs/rules/cloud-connector/examples/serve-static-assets-from-azure.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ To serve static assets from an Azure Blob Storage container:
1515
4. Enter the bucket URL. Here’s how to structure it:
1616
- **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`.
1717
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.
18-
6. Click **Next** and enter a descriptive name like "Serve static assets from Azure" in Cloud Connector name.
18+
6. Click **Next** and enter a descriptive name like `Serve static assets from Azure` in **Cloud Connector name**.
1919
7. Under **If**, select **Custom filter expression** and enter the following expression:
20-
`http.request.full_uri wildcard "https://<YOUR_HOSTNAME>/static-assets/*"`<br />
20+
`http.request.full_uri wildcard "http*://<YOUR_HOSTNAME>/static-assets/*"`<br />
2121
8. Select **Deploy** to activate the rule.
2222

23-
This setup ensures that all traffic to `https://<YOUR_HOSTNAME>/static-assets/*` is served from your Azure Blob Storage container. Make sure to replace `<YOUR_HOSTNAME>` with your actual hostname and adjust the example paths according to your setup.
23+
This setup ensures that all traffic matching `http*://<YOUR_HOSTNAME>/static-assets/*` (HTTPS and HTTP requests) is served from your Azure Blob Storage container. Make sure to replace `<YOUR_HOSTNAME>` with your actual hostname and adjust the example paths according to your setup.

src/content/docs/rules/transform/url-rewrite/create-dashboard.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ If you choose to deploy your rewrite URL rule, the new rule will be enabled. If
5454

5555
The Cloudflare dashboard offers a simplified user interface for creating URL rewrites based on wildcard matching and replacement. When you select **Wildcard pattern**, you will have the following parameters available:
5656

57-
- **Request URL**: Enter the [wildcard pattern](/ruleset-engine/rules-language/operators/#wildcard-matching) using the asterisk (`*`) character to match multiple requests. For example, `https://*.example.com/*`.
57+
- **Request URL**: Enter the [wildcard pattern](/ruleset-engine/rules-language/operators/#wildcard-matching) using the asterisk (`*`) character to match multiple requests. For example, `http*://*.example.com/*`.
5858

5959
- **Then rewrite the path and/or query**: Define the [URL rewrite settings](/rules/transform/url-rewrite/reference/parameters/) including:
6060
- **Path** > **Target path**: Enter the URI path to match, which can include wildcards (for example, `/oldpath/*`).

src/content/docs/rules/url-forwarding/single-redirects/create-dashboard.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ import { Render } from "~/components";
1414
4. (Optional) Select one of the rule templates that address common use cases. Then, review and adjust the proposed rule configuration.
1515
5. Enter a descriptive name for the rule in **Rule name**.
1616
6. Under **When incoming requests match**, select one of the following options:
17+
1718
- **Wildcard pattern**: The rule will only apply to traffic matching the wildcard pattern.
18-
- **Request URL**: Enter the [wildcard pattern](/ruleset-engine/rules-language/operators/#wildcard-matching) using the asterisk (`*`) character to match multiple requests. For example, `https://*.example.com/files/*`.
19+
- **Request URL**: Enter the [wildcard pattern](/ruleset-engine/rules-language/operators/#wildcard-matching) using the asterisk (`*`) character to match multiple requests. For example, `http*://*.example.com/files/*`.
1920
- **Then**: Define the [URL redirect settings](/rules/url-forwarding/single-redirects/settings/) including:
2021
- **Target URL**: Enter the target URL, which can be static (for example, `https://example.com`) or dynamic (for example, `https://example.com/${1}/files/${2}`). Use [wildcard replacement](/ruleset-engine/rules-language/functions/#wildcard_replace) such as `${1}` and `${2}` to define dynamic target URLs.
2122
- **Status code**: Select the status code for the redirect (for example, `301`).
@@ -24,6 +25,7 @@ import { Render } from "~/components";
2425
- **Then**: Define the [URL redirect settings](/rules/url-forwarding/single-redirects/settings/) for all incoming requests.
2526
- **Custom filter expression**: The rule will only apply to traffic matching a custom expression. Define the [rule expression](/ruleset-engine/rules-language/expressions/edit-expressions/) to configure which requests should be redirected.
2627
- **Then**: Define the [URL redirect settings](/rules/url-forwarding/single-redirects/settings/) for requests matching the custom rule expression.
28+
2729
7. To save and deploy your rule, select **Deploy**. If you are not ready to deploy your rule, select **Save as Draft**.
2830

2931
<Render

src/content/docs/ruleset-engine/rules-language/operators.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,11 @@ When using the `wildcard`/`strict wildcard` operator, the entire field value mus
197197

198198
```txt title="Example A"
199199
# The following expression:
200-
http.request.full_uri wildcard "https://example.com/a/*"
200+
http.request.full_uri wildcard "http*://example.com/a/*"
201201
202202
# Would match the following URIs:
203203
# - https://example.com/a/ (the '*' matches zero characters)
204+
# - http://example.com/a/
204205
# - https://example.com/a/page.html
205206
# - https://example.com/a/sub/folder/?name=value
206207
@@ -233,7 +234,7 @@ http.request.full_uri wildcard "*.example.com/*/page.html"
233234

234235
```txt
235236
# The following expression:
236-
http.request.full_uri wildcard "*.example.com/*" or http.request.full_uri wildcard "example.com/*"
237+
http.request.full_uri wildcard "*.example.com/*" or http.request.full_uri wildcard "http*://example.com/*"
237238
238239
# Would match the following URIs:
239240
# - https://example.com/folder/list.htm

0 commit comments

Comments
 (0)