turbot/cloudflare
steampipe plugin install cloudflare

Table: cloudflare_page_rule - Query Cloudflare Page Rules using SQL

Cloudflare Page Rules is a feature within Cloudflare that allows you to customize your website's functionality and performance on a page-by-page basis. It provides a centralized way to set up and manage rules for various web pages, including redirection, caching, security, and more. Cloudflare Page Rules helps you optimize the delivery of your web content and take appropriate actions when predefined conditions are met.

Table Usage Guide

The cloudflare_page_rule table provides insights into the rules set up for specific web pages within Cloudflare. As a DevOps engineer, explore rule-specific details through this table, including targets, actions, and associated metadata. Utilize it to uncover information about rules, such as those related to caching, security, or redirection, and the verification of their correct implementation.

Examples

Basic info

Explore which rules are active within your Cloudflare settings to prioritize their importance and manage your web traffic effectively. This can help optimize your website's performance and security.

select
id,
zone_id,
status,
priority
from
cloudflare_page_rule;
select
id,
zone_id,
status,
priority
from
cloudflare_page_rule;

List disabled page rules

Explore which page rules are currently disabled in your Cloudflare settings. This information can help you understand potential vulnerabilities or areas of your website that are not currently protected by active rules.

select
id,
zone_id,
status
from
cloudflare_page_rule
where
status = 'disabled';
select
id,
zone_id,
status
from
cloudflare_page_rule
where
status = 'disabled';

List page rules that do not have the Always Online feature enabled

Assess the elements within your website's page rules to identify those that lack the Always Online feature. This can be useful to ensure your site remains accessible even when your server goes offline, enhancing user experience and site reliability.

select
id,
zone_id,
action ->> 'value' as always_online
from
cloudflare_page_rule,
jsonb_array_elements(actions) as action
where
action ->> 'id' = 'always_online'
and action ->> 'value' = 'off';
select
id,
zone_id,
json_extract(action.value, '$.value') as always_online
from
cloudflare_page_rule,
json_each(actions) as action
where
json_extract(action.value, '$.id') = 'always_online'
and json_extract(action.value, '$.value') = 'off';

Schema for cloudflare_page_rule

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form, e.g. connection_name.
actionsjsonbA list of actions to perform if the targets of this rule match the request. Actions can redirect the url to another url or override settings (but not both).
created_ontimestamp with time zoneThe time when the page rule is created.
idtext=Specifies the Page Rule identifier.
modified_ontimestamp with time zoneThe time when the page rule was last modified.
prioritybigintA number that indicates the preference for a page rule over another.
statustextSpecifies the status of the page rule.
targetsjsonbA list of targets to evaluate on a request.
titletextTitle of the resource.
zone_idtext=Specifies the zone identifier.

Export

This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- cloudflare

You can pass the configuration to the command with the --config argument:

steampipe_export_cloudflare --config '<your_config>' cloudflare_page_rule