Skip to content

Commit 010fe93

Browse files
committed
Update two snippet examples with rules also
1 parent d462b35 commit 010fe93

File tree

2 files changed

+49
-14
lines changed

2 files changed

+49
-14
lines changed

src/content/docs/rules/snippets/examples/maintenance.mdx

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,33 @@ title: Maintenance page
1212
description: Serve a custom maintenance page instead of fetching content from the origin server or cache. Ideal for downtime notifications, planned maintenance, or emergency messages.
1313
---
1414

15+
## Snippet code
16+
1517
```js
1618
// Define your customizable inputs
1719
const statusCode = 503;
1820
const title = "We'll Be Right Back!";
19-
const message = "Our site is currently undergoing scheduled maintenance. We’re working hard to bring you a better experience. Thank you for your patience and understanding.";
21+
const message =
22+
"Our site is currently undergoing scheduled maintenance. We’re working hard to bring you a better experience. Thank you for your patience and understanding.";
2023
const estimatedTime = "1 hour";
2124
const contactEmail = "[email protected]";
2225
const contactPhone = "+1 234 567 89";
2326

2427
export default {
25-
async fetch(request) {
26-
// Serve the maintenance page as a response
27-
return new Response(generateMaintenancePage(), {
28-
status: statusCode,
29-
headers: {
30-
"Content-Type": "text/html",
31-
"Retry-After": "3600", // Suggest retry after 1 hour
32-
},
33-
});
34-
},
28+
async fetch(request) {
29+
// Serve the maintenance page as a response
30+
return new Response(generateMaintenancePage(), {
31+
status: statusCode,
32+
headers: {
33+
"Content-Type": "text/html",
34+
"Retry-After": "3600", // Suggest retry after 1 hour
35+
},
36+
});
37+
},
3538
};
3639

3740
function generateMaintenancePage() {
38-
return `
41+
return `
3942
<!DOCTYPE html>
4043
<html lang="en">
4144
<head>
@@ -105,3 +108,19 @@ function generateMaintenancePage() {
105108
`;
106109
}
107110
```
111+
112+
## Snippet rule
113+
114+
Configure a custom filter expression:
115+
116+
| Field | Operator | Value |
117+
| ----------------- | -------------- | ----------- |
118+
| IP Source Address | is not in list | `admin_ips` |
119+
120+
If you are using the Expression Editor, enter the following expression:
121+
122+
```txt
123+
(not ip.src in $admin_ips)
124+
```
125+
126+
The [IP list](/waf/tools/lists/custom-lists/#ip-lists) `admin_ips` was previously created and contains the list of IP addresses of the site administrators, which will be able to access the site during the maintenance period.

src/content/docs/rules/snippets/examples/slow-suspicious-requests.mdx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
type: example
33
summary: Define a delay to be used when incoming requests match a rule you
4-
consider suspicious.
4+
consider suspicious based on the bot score.
55
goal:
66
- Other
77
operation:
@@ -11,9 +11,11 @@ products:
1111
pcx_content_type: example
1212
title: Slow down suspicious requests
1313
description: Define a delay to be used when incoming requests match a rule you
14-
consider suspicious.
14+
consider suspicious based on the bot score.
1515
---
1616

17+
## Snippet code
18+
1719
```js
1820
export default {
1921
async fetch(request) {
@@ -30,3 +32,17 @@ export default {
3032
},
3133
};
3234
```
35+
36+
## Snippet rule
37+
38+
Configure a custom filter expression:
39+
40+
| Field | Operator | Value |
41+
| --------- | --------- | ----- |
42+
| Bot Score | less than | `10` |
43+
44+
If you are using the Expression Editor, enter the following expression:
45+
46+
```txt
47+
(cf.bot_management.score lt 10)
48+
```

0 commit comments

Comments
 (0)