Skip to content

Commit e609f37

Browse files
committed
block page
1 parent 2d46467 commit e609f37

File tree

3 files changed

+82
-2
lines changed

3 files changed

+82
-2
lines changed

src/content/docs/learning-paths/replace-vpn/build-policies/block-page.mdx

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 5
66
---
77

8-
import { Render } from "~/components";
8+
import { Render, Tabs, TabItem } from "~/components";
99

1010
With Cloudflare Zero Trust, you can deliver actionable feedback to users when they are blocked by a Gateway policy. Custom block messages can reduce user confusion and decrease your IT ticket load.
1111

@@ -35,6 +35,8 @@ The Gateway custom block page is a different concept from [Access custom block p
3535

3636
For DNS policies, you will need to enable the block page on a per-policy basis.
3737

38+
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
39+
3840
<Render
3941
file="gateway/add-block-page"
4042
product="cloudflare-one"
@@ -45,6 +47,47 @@ For DNS policies, you will need to enable the block page on a per-policy basis.
4547

4648
/>
4749

50+
</TabItem>
51+
<TabItem label="Terraform (v5)">
52+
53+
1. Add the following permission to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/api_token):
54+
- `Zero Trust Write`
55+
56+
2. Choose a DNS policy with a Block action.
57+
58+
3. In the policy's [`rule_settings`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zero_trust_gateway_policy), turn on `block_page_enabled`. If you have configured a [custom Gateway block page](/cloudflare-one/policies/gateway/block-page/#customize-the-block-page), you can optionally show an additional `block_reason` when traffic is blocked by this policy.
59+
60+
```tf
61+
resource "cloudflare_zero_trust_gateway_policy" "dns_block_security_categories" {
62+
name = "Block DNS Security Categories"
63+
enabled = true
64+
account_id = var.cloudflare_account_id
65+
description = "Managed by Terraform - Generic security policy based on Cloudflare Threat Intelligence categories."
66+
precedence = 101
67+
action = "block"
68+
filters = ["dns"]
69+
/* Categories being enabled here:
70+
- 80: "Command and Control & Botnet"
71+
- 83: "Cryptomining"
72+
- 117: "Malware"
73+
- 131: "Phishing"
74+
- 153: "Spyware"
75+
- 175: "DNS Tunneling"
76+
- 176: "DGA Domains"
77+
- 178: "Brand Embedding"
78+
*/
79+
traffic = "any(dns.security_category[*] in {80 83 117 131 153 175 176 178})"
80+
identity = ""
81+
82+
rule_settings = {
83+
block_page_enabled = true
84+
block_reason = "This domain has been flagged as a potential security risk." // Adds an additional message to the custom block page. Requires enabling custom block page in cloudflare_zero_trust_gateway_settings.
85+
}
86+
}
87+
```
88+
</TabItem>
89+
</Tabs>
90+
4891
### Customize the block page
4992

5093
<Render file="gateway/customize-block-page" product="cloudflare-one" />

src/content/partials/cloudflare-one/gateway/customize-block-page.mdx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
{}
33
---
44

5+
import { Tabs, TabItem } from "~/components";
6+
57
You can customize the Cloudflare-hosted block page by making global changes that Gateway will display every time a user reaches your block page. Customizations will apply regardless of the type of policy (DNS or HTTP) that blocks the traffic.
68

79
To customize your block page:
810

11+
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
12+
913
1. In [Zero Trust](https://one.dash.cloudflare.com), go to **Settings** > **Custom Pages**.
1014
2. Under **Account Gateway block page**, select **Customize**.
1115
3. Choose **Custom Gateway block page**. Gateway will display a preview of your custom block page. Available customizations include:
@@ -17,4 +21,35 @@ To customize your block page:
1721
- Background color
1822
4. Select **Save**.
1923

24+
25+
</TabItem>
26+
<TabItem label="Terraform (v5)">
27+
28+
1. Add the following permission to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/api_token):
29+
- `Zero Trust Write`
30+
31+
2. In [`cloudflare_zero_trust_gateway_settings`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zero_trust_gateway_settings), configure the `block_page` argument with your customizations:
32+
33+
```tf
34+
resource "cloudflare_zero_trust_gateway_settings" "team_name" {
35+
account_id = var.cloudflare_account_id
36+
settings = {
37+
block_page = {
38+
enabled = true //do not use the default Gateway block page
39+
mode = "customized_block_page" //use a custom block page
40+
name = "Cloudflare"
41+
logo_path = "https://logos.com/a.png"
42+
header_text = "--header--"
43+
footer_text = "--footer--"
44+
mailto_address = "[email protected]"
45+
mailto_subject = "Blocked Request"
46+
background_color = "#ffffff"
47+
suppress_footer = false
48+
}
49+
}
50+
}
51+
```
52+
</TabItem>
53+
</Tabs>
54+
2055
Gateway will now display a custom Gateway block page when your users visit a blocked website.

src/content/partials/cloudflare-one/warp/warp-sessions-gateway.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ To configure a session timeout for a Gateway policy:
2525
1. Add the following permission to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/api_token):
2626
- `Zero Trust Write`
2727

28-
2. Choose a Network (`l4`) or HTTP (`http`) Allow policy. Use the [`check_session` argument](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zero_trust_gateway_policy) to enable and configure a session timeout:
28+
2. Choose a Network (`l4`) or HTTP (`http`) policy with an Allow action.
29+
30+
3. In the policy's [`rule_settings`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zero_trust_gateway_policy), use the `check_session` argument to enable and configure a session timeout:
2931

3032
```tf
3133
resource "cloudflare_zero_trust_gateway_policy" "network_allow_wiki_IPs" {

0 commit comments

Comments
 (0)