Example custom error rules


目录

The provided examples use the following fields in their rule expressions:

Custom JSON response for all 5XX errors

This example configures a custom JSON error response for all 5XX errors (500-599) in a zone. The HTTP status code of the custom error response will be set to 530.

Dashboard

Custom error rule configuration:

API

PUT /zones/{zone_id}/rulesets/phases/{ruleset_phase}/entrypoint

This PUT request, corresponding to the Update a zone entry point ruleset operation, replaces any existing rules in the http_custom_errors phase entry point ruleset.

Custom HTML response with updated status code

This example configures a custom HTML error response for responses with a 500 HTTP status code, and redefines the response status code to 503.

Dashboard

Custom error rule configuration:

API

PUT /zones/{zone_id}/rulesets/phases/{ruleset_phase}/entrypoint

This PUT request, corresponding to the Update a zone entry point ruleset operation, replaces any existing rules in the http_custom_errors phase entry point ruleset.

Custom HTML response for Cloudflare 1020 errors

This example configures a custom HTML error response for Cloudflare error 1020 (Access Denied).

Dashboard

Custom error rule configuration:

API

PUT /zones/{zone_id}/rulesets/phases/{ruleset_phase}/entrypoint

This PUT request, corresponding to the Update a zone entry point ruleset operation, replaces any existing rules in the http_custom_errors phase entry point ruleset.

Custom error asset created from a URL

This example configures a custom error rule returning a previously created custom error asset named 500_error_template for responses with a 500 HTTP status code.

Dashboard

Custom error rule configuration:

API

PUT /zones/{zone_id}/rulesets/phases/{ruleset_phase}/entrypoint

This PUT request, corresponding to the Update a zone entry point ruleset operation, replaces any existing rules in the http_custom_errors phase entry point ruleset.


版本号 #3
由 壳壳虫 创建于 2026-11-01 03:55:56 UTC
由 cocobook-sync 更新于 2026-11-04 17:48:21 UTC