How can I configure a custom response for AWS WAF managed rules?
3 minute read
I want to configure a custom response for requests that are blocked by an AWS WAF managed rule inside an AWS WAF managed rule group.
Set the AWS WAF managed rule that you want to configure a custom response for in the Count rule action. Then, create a custom rule below the managed rule group to generate the custom response. If the request matches the label that the managed rule set in Count generates, then the response is sent.
In the navigation pane, choose Web ACLs, and then choose your web access control list (web ACL).
Choose Custom response bodies, and then choose Create custom response body.
For Response body object name, enter a name.
For Content type, choose Plain text. Note: The response body can be JSON, HTML, or plaintext.
In Response body, enter your response message, and then choose Save.
Note: Amazon CloudFront and Amazon API Gateway also support custom responses. However, AWS WAF custom responses take priority over any response specifications that are defined in your protected resource. For more information, see Custom responses for Block actions.