選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

Rule - AWS WAFV2
此頁面尚未翻譯為您的語言。 請求翻譯

Rule

A single rule, which you can use in a WebACL or RuleGroup to identify web requests that you want to manage in some way. Each rule includes one top-level Statement that AWS WAF uses to identify matching web requests, and parameters that govern how AWS WAF handles them.

Contents

Name

The name of the rule.

If you change the name of a Rule after you create it and you want the rule's metric name to reflect the change, update the metric name in the rule's VisibilityConfig settings. AWS WAF doesn't automatically update the metric name when you update the rule name.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: ^[\w\-]+$

Required: Yes

Priority

If you define more than one Rule in a WebACL, AWS WAF evaluates each request against the Rules in order based on the value of Priority. AWS WAF processes rules with lower priority first. The priorities don't need to be consecutive, but they must all be different.

Type: Integer

Valid Range: Minimum value of 0.

Required: Yes

Statement

The AWS WAF processing statement for the rule, for example ByteMatchStatement or SizeConstraintStatement.

Type: Statement object

Required: Yes

VisibilityConfig

Defines and enables Amazon CloudWatch metrics and web request sample collection.

If you change the name of a Rule after you create it and you want the rule's metric name to reflect the change, update the metric name as well. AWS WAF doesn't automatically update the metric name.

Type: VisibilityConfig object

Required: Yes

Action

The action that AWS WAF should take on a web request when it matches the rule statement. Settings at the web ACL level can override the rule action setting.

This is used only for rules whose statements do not reference a rule group. Rule statements that reference a rule group include RuleGroupReferenceStatement and ManagedRuleGroupStatement.

You must specify either this Action setting or the rule OverrideAction setting, but not both:

  • If the rule statement does not reference a rule group, use this rule action setting and not the rule override action setting.

  • If the rule statement references a rule group, use the override action setting and not this action setting.

Type: RuleAction object

Required: No

CaptchaConfig

Specifies how AWS WAF should handle CAPTCHA evaluations. If you don't specify this, AWS WAF uses the CAPTCHA configuration that's defined for the web ACL.

Type: CaptchaConfig object

Required: No

ChallengeConfig

Specifies how AWS WAF should handle Challenge evaluations. If you don't specify this, AWS WAF uses the challenge configuration that's defined for the web ACL.

Type: ChallengeConfig object

Required: No

OverrideAction

The action to use in the place of the action that results from the rule group evaluation. Set the override action to none to leave the result of the rule group alone. Set it to count to override the result to count only.

You can only use this for rule statements that reference a rule group, like RuleGroupReferenceStatement and ManagedRuleGroupStatement.

Note

This option is usually set to none. It does not affect how the rules in the rule group are evaluated. If you want the rules in the rule group to only count matches, do not use this and instead use the rule action override option, with Count action, in your rule group reference statement settings.

Type: OverrideAction object

Required: No

RuleLabels

Labels to apply to web requests that match the rule match statement. AWS WAF applies fully qualified labels to matching web requests. A fully qualified label is the concatenation of a label namespace and a rule label. The rule's rule group or web ACL defines the label namespace.

Note

Any rule that isn't a rule group reference statement or managed rule group statement can add labels to matching web requests.

Rules that run after this rule in the web ACL can match against these labels using a LabelMatchStatement.

For each label, provide a case-sensitive string containing optional namespaces and a label name, according to the following guidelines:

  • Separate each component of the label with a colon.

  • Each namespace or name can have up to 128 characters.

  • You can specify up to 5 namespaces in a label.

  • Don't use the following reserved words in your label specification: aws, waf, managed, rulegroup, webacl, regexpatternset, or ipset.

For example, myLabelName or nameSpace1:nameSpace2:myLabelName.

Type: Array of Label objects

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。