fail_​action

Version: v2025-01-13Includes use: Yes

Behavior name: Site Failover

Specifies how to respond when the origin is not available: by serving stale content, by serving an error page, or by redirecting. To apply this behavior, you should match on an origin_timeout or match_response_code.

Default behavior

These samples reflect the behavior's default settings. You can use these as is in your configurations or make adjustments based on the behavior's available options.

data "akamai_property_rules_builder" "fail_action" {
  rules_v2025_02_18 {
    name     = "Site Failover"
    comments = "Specifies how to respond when the origin is not available"
    behavior {
      fail_action {
        enabled                = true
        action_type            = "REDIRECT"
        redirect_hostname_type = "ALTERNATE"
        redirectHostname       = ""
        redirect_custom_path   = true
        redirect_path          = ""
        redirect_method        = 302
        preserve_query_string  = true
        modify_protocol        = false
      }
    }
  }
}
"behaviors": [
  {
  "name": "failAction",
  "options": {
    "enabled": true,
    "actionType": "REDIRECT",
    "redirectHostnameType": "ALTERNATE",
    "redirectHostname": "",
    "redirectCustomPath": true,
    "redirectPath": "",
    "redirectMethod": 302,
    "preserveQueryString": true,
    "modifyProtocol": false
    }
  }
]

Options

Option Description
enabled
When enabled in case of a failure to contact the origin, the current behavior applies.
action_type
Specifies the basic action to take when there is a failure to contact the origin. Value is one of:
  • SERVE_STALE. Serves content that is already in the cache.
  • REDIRECT. Specifies a redirect action. Use with these options:
    • redirect_hostname_type
    • redirect_hostname
    • redirect_custom_path
    • redirect_path
    • redirect_method
    • modify_protocol
    • protocol
  • RECREATED_CO. Serves alternate content from your network. Use with these options:
    • content_hostname
    • content_custom_path
    • content_path
  • RECREATED_CEX. Serves alternate content from an external network. Use with these options:
    • cex_hostname
    • cex_custom_path
    • cex_path
  • RECREATED_NS. Serves NetStorage content. Use with these options:
    • net_storage_hostname
    • net_storage_path
    • cp_code
  • DYNAMIC. Allows you to serve dynamic SaaS content if SaaS acceleration is available on your contract. Use with these options:
    • dynamic_method
    • dynamic_custom_path
    • saas_type
    • saas_suffix
    • saas_regex
    • saas_replace
saas_type
Identifies the component of the request that identifies the SaaS dynamic fail action. Value is one of:
  • COOKIE
  • HOSTNAME
  • PATH
  • QUERY_STRING
saas_cname_enabled
Specifies whether to use a CNAME chain to determine the hostname for the SaaS dynamic fail action.
saas_cname_level
Specifies the number of elements in the CNAME chain backwards from the edge hostname that determines the hostname for the SaaS dynamic fail action.
saas_cookie
Specifies whether to use a CNAME chain to determine the hostname for the SaaS dynamic fail action.
saas_query_string
Specifies the name of the query parameter that identifies this SaaS dynamic fail action.
saas_regex
Specifies the substitution pattern (a Perl-compatible regular expression) that defines the SaaS dynamic fail action.
saas_replace
Specifies the replacement pattern that defines the SaaS dynamic fail action.
saas_suffix
Specifies the static portion of the SaaS dynamic fail action.
dynamic_method
Specifies the redirect method. Value is one of:
  • SERVE_301. A 301 redirect response.
  • SERVE_302. A 302 redirect response.
  • SERVE_ALTERNATE. Serve an alternate response.
dynamic_custom_path
Allows you to modify the original requested path.
dynamic_path
Specifies the new path.
redirect_hostname_type
Whether to preserve or customize the hostname. Value is one of:
  • ORIGINAL. Preserve the original hostname in the redirect.
  • ALTERNATE. Specify a redirect_hostname.
redirect_hostname
When the action_type is REDIRECT and the redirect_hostname_type is ALTERNATE this specifies the hostname for the redirect.
redirect_custom_path
Uses the redirect_path to customize a new path.
redirect_path
Specifies a new path.
redirect_method
Specifies the HTTP response code. Value is one of:
  • 301
  • 302
content_hostname
Specifies the static hostname for the alternate redirect.
content_custom_path
Specifies a custom redirect path.
content_path
Specifies a custom redirect path.
net_storage_hostname
When the action_type is RECREATED_NS specifies the NetStorage origin to serve the alternate content. Contact Akamai Professional Services for your NetStorage origin's id. Contains:
  • cp_code. Identifies a CP code assigned to this storage group.
  • download_domain_name. Domain name from which content can be downloaded.
  • g2o_token. Signature Header Authentication key.
  • id. Unique identifier for the storage group.
  • name. Name of the storage group.
net_storage_path
When the action_type is RECREATED_NS specifies the path for the NetStorage request.
cex_hostname
Specifies a hostname.
cex_custom_path
Specifies a custom path.
cex_path
Specifies a custom path.
cp_code
Specifies a CP code for which to log errors for the NetStorage location. Contains a CP code id without the prefix.
status_code
Assigns a new HTTP status code to the failure response. Value is one of:
  • 100
  • 101
  • 102
  • 103
  • 122
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 226
  • 400
  • 401
  • 402
  • 403
  • 404
  • 405
  • 406
  • 407
  • 408
  • 409
  • 410
  • 411
  • 412
  • 413
  • 414
  • 415
  • 416
  • 417
  • 422
  • 423
  • 424
  • 428
  • 429
  • 431
  • 444
  • 449
  • 450
  • 499
  • 500
  • 501
  • 502
  • 503
  • 504
  • 505
  • 506
  • 507
  • 509
  • 510
  • 511
  • 598
  • 599
preserve_query_string
When using either content_custom_path, cex_custom_path, dynamic_custom_path, or redirect_custom_path to specify a custom path, enabling this passes in the original request's query string as part of the path.
modify_protocol
Modifies the redirect's protocol using the value of the protocol field.
protocol
When the action_type is REDIRECT and modify_protocol is enabled, this specifies the redirect's protocol. Value is one of:
  • HTTP
  • HTTPS