@Generated(value="software.amazon.awssdk:codegen") public final class RateBasedStatement extends Object implements SdkPojo, Serializable, ToCopyableBuilder<RateBasedStatement.Builder,RateBasedStatement>
A rate-based rule tracks the rate of requests for each originating IP address, and triggers the rule action when the rate exceeds a limit that you specify on the number of requests in any 5-minute time span. You can use this to put a temporary block on requests from an IP address that is sending excessive requests.
When the rule action triggers, AWS WAF blocks additional requests from the IP address until the request rate falls below the limit.
You can optionally nest another statement inside the rate-based statement, to narrow the scope of the rule so that it only counts requests that match the nested statement. For example, based on recent requests that you have seen from an attacker, you might create a rate-based rule with a nested AND rule statement that contains the following nested statements:
An IP match statement with an IP set that specified the address 192.0.2.44.
A string match statement that searches in the User-Agent header for the string BadBot.
In this rate-based rule, you also define a rate limit. For this example, the rate limit is 1,000. Requests that meet both of the conditions in the statements are counted. If the count exceeds 1,000 requests per five minutes, the rule action triggers. Requests that do not meet both conditions are not counted towards the rate limit and are not affected by this rule.
You cannot nest a RateBasedStatement, for example for use inside a NotStatement or
OrStatement. It can only be referenced as a top-level statement within a rule.
| Modifier and Type | Class and Description |
|---|---|
static interface |
RateBasedStatement.Builder |
| Modifier and Type | Method and Description |
|---|---|
RateBasedStatementAggregateKeyType |
aggregateKeyType()
Setting that indicates how to aggregate the request counts.
|
String |
aggregateKeyTypeAsString()
Setting that indicates how to aggregate the request counts.
|
static RateBasedStatement.Builder |
builder() |
boolean |
equals(Object obj) |
boolean |
equalsBySdkFields(Object obj) |
ForwardedIPConfig |
forwardedIPConfig()
The configuration for inspecting IP addresses in an HTTP header that you specify, instead of using the IP address
that's reported by the web request origin.
|
<T> Optional<T> |
getValueForField(String fieldName,
Class<T> clazz) |
int |
hashCode() |
Long |
limit()
The limit on requests per 5-minute period for a single originating IP address.
|
Statement |
scopeDownStatement()
An optional nested statement that narrows the scope of the rate-based statement to matching web requests.
|
List<SdkField<?>> |
sdkFields() |
static Class<? extends RateBasedStatement.Builder> |
serializableBuilderClass() |
RateBasedStatement.Builder |
toBuilder() |
String |
toString()
Returns a string representation of this object.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcopypublic final Long limit()
The limit on requests per 5-minute period for a single originating IP address. If the statement includes a
ScopeDownStatement, this limit is applied only to the requests that match the statement.
ScopeDownStatement, this limit is applied only to the requests that match the statement.public final RateBasedStatementAggregateKeyType aggregateKeyType()
Setting that indicates how to aggregate the request counts. The options are the following:
IP - Aggregate the request counts on the IP address from the web request origin.
FORWARDED_IP - Aggregate the request counts on the first IP address in an HTTP header. If you use this, configure
the ForwardedIPConfig, to specify the header to use.
If the service returns an enum value that is not available in the current SDK version, aggregateKeyType
will return RateBasedStatementAggregateKeyType.UNKNOWN_TO_SDK_VERSION. The raw value returned by the
service is available from aggregateKeyTypeAsString().
IP - Aggregate the request counts on the IP address from the web request origin.
FORWARDED_IP - Aggregate the request counts on the first IP address in an HTTP header. If you use this,
configure the ForwardedIPConfig, to specify the header to use.
RateBasedStatementAggregateKeyTypepublic final String aggregateKeyTypeAsString()
Setting that indicates how to aggregate the request counts. The options are the following:
IP - Aggregate the request counts on the IP address from the web request origin.
FORWARDED_IP - Aggregate the request counts on the first IP address in an HTTP header. If you use this, configure
the ForwardedIPConfig, to specify the header to use.
If the service returns an enum value that is not available in the current SDK version, aggregateKeyType
will return RateBasedStatementAggregateKeyType.UNKNOWN_TO_SDK_VERSION. The raw value returned by the
service is available from aggregateKeyTypeAsString().
IP - Aggregate the request counts on the IP address from the web request origin.
FORWARDED_IP - Aggregate the request counts on the first IP address in an HTTP header. If you use this,
configure the ForwardedIPConfig, to specify the header to use.
RateBasedStatementAggregateKeyTypepublic final Statement scopeDownStatement()
An optional nested statement that narrows the scope of the rate-based statement to matching web requests. This can be any nestable statement, and you can nest statements at any level below this scope-down statement.
public final ForwardedIPConfig forwardedIPConfig()
The configuration for inspecting IP addresses in an HTTP header that you specify, instead of using the IP address that's reported by the web request origin. Commonly, this is the X-Forwarded-For (XFF) header, but you can specify any header name.
If the specified header isn't present in the request, AWS WAF doesn't apply the rule to the web request at all.
This is required if AggregateKeyType is set to FORWARDED_IP.
If the specified header isn't present in the request, AWS WAF doesn't apply the rule to the web request at all.
This is required if AggregateKeyType is set to FORWARDED_IP.
public RateBasedStatement.Builder toBuilder()
toBuilder in interface ToCopyableBuilder<RateBasedStatement.Builder,RateBasedStatement>public static RateBasedStatement.Builder builder()
public static Class<? extends RateBasedStatement.Builder> serializableBuilderClass()
public final boolean equalsBySdkFields(Object obj)
equalsBySdkFields in interface SdkPojopublic final String toString()
Copyright © 2021. All rights reserved.