Modifies the attributes of one or more forwarding rules.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes UpdateRulesAttribute

The operation that you want to perform. Set the value to UpdateRulesAttribute.

ClientToken String No 123e4567-e89b-12d3-a456-426655440000

The client token that is used to ensure the idempotence of the request.

You can use the client to generate the value, but you must ensure that it is unique among different requests. ClientToken can contain only ASCII characters.

Note If you do not set this parameter, the system automatically uses RequestId as ClientToken. RequestId may be different for each API request.
Rules Array Yes

The list of forwarding rules. You can specify at most 10 forwarding rules in each request.

Priority Integer No 10

The priority of the forwarding rule. Valid values: 1 to 10000. A lower value specifies a higher priority.

Note The priority of each forwarding rule within a listener must be unique.
RuleName String No rule-instance-test

The name of the forwarding rule. The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.

RuleActions Array No

The actions of the forwarding rule.

FixedResponseConfig Object No

The configuration of the action to return a custom response.

Content String No dssacav

The content of the custom response. The content can be up to 1 KB in size, and can contain only ASCII characters.

ContentType String No text/plain

The content type.

Valid values: text/plain, text/css, text/html, application/javascript, and application/json.

HttpCode String No 200

The HTTP status code to return. Valid values: HTTP_2xx, HTTP_4xx, and HTTP_5xx. x must be a digit.

ForwardGroupConfig Object No

The configuration of the action to forward requests to server groups.

ServerGroupTuples Array No

The list of server groups to which requests are forwarded.

ServerGroupId String No sg-atstuj3rtoptyui****

The server group to which requests are forwarded.

Weight Integer No 2

The weight of the server group. A larger value specifies a higher weight. A server group with a higher weight receives more requests. Valid values: 1 to 100.

ServerGroupStickySession Object No

The configuration of session persistence for server groups.

Enabled Boolean No false

Specifies whether to enable session persistence. Valid values:

  • true: enables session persistence.
  • false (default): disables session persistence.
Timeout Integer No 2

The timeout period. Unit: seconds. Valid values: 1 to 86400.

InsertHeaderConfig Object No

The configuration of the action to insert a header.

CoverEnabled Boolean No false

Specifies whether to overwrite the request header. Valid values:

  • true: overwrites the request header.
  • false (default): does not overwrite the request header.
Key String No test

The key of the header. The key must be 1 to 40 characters in length, and can contain lowercase letters, digits, underscores (_), and hyphens (-). The key specified in the InsertHeader parameter must be unique.

Note You cannot set one of the following keys (case-insensitive): slb-id, slb-ip, x-forwarded-for, x-forwarded-proto, x-forwarded-eip, x-forwarded-port, x-forwarded-client-srcport, connection, upgrade, content-length, transfer-encoding, keep-alive, te, host, cookie, remoteip, and authority.
Value String No UserDefined

The value of the header to be inserted.

  • If ValueType is set to SystemDefined, you can set one of the following header values:
    • ClientSrcPort: the client port.
    • ClientSrcIp: the client IP address.
    • Protocol: the request protocol (HTTP or HTTPS).
    • SLBId: the ID of the Application Load Balancer (ALB) instance.
    • SLBPort: the listening port.
  • If ValueType is set to UserDefined, you can specify a custom header value. The header value must be 1 to 128 characters in length, and can contain printable characters whose ASCII values are greater than or equal to 32 and lower than 127. You can use asterisks (*) and question marks (?) as wildcards. The value cannot start or end with a space character.
  • If ValueType is set to ReferenceHeader, you can reference one of the request headers. The header value must be 1 to 128 characters in length, and can contain lowercase letters, digits, underscores (_), and hyphens (-).
ValueType String No UserDefined

The type of the header. Valid values:

  • UserDefined: a user-defined header
  • ReferenceHeader: references from a request header
  • SystemDefined: a system-defined header
Order Integer Yes 1

The priority of the action. Valid values: 1 to 50000. A lower value specifies a higher priority. The actions of a forwarding rule are applied in descending order of priority. This parameter is required. The priority of each action within a forwarding rule must be unique.

RedirectConfig Object No

The configuration of the redirect action.

Host String No www.example.com

The hostname to which requests are redirected.

Limits:

  • The hostname must be 3 to 128 characters in length, and can contain lowercase letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).
  • The hostname must contain at least one period (.) but cannot start or end with a period (.).
  • The rightmost domain label can contain only letters, asterisks (*), and question marks (?), and cannot contain digits or hyphens (-).
  • The domain labels cannot start or end with hyphens (-). Asterisks (*) and question marks (?) can appear anywhere in a domain label.
HttpCode String No 301

The redirect type. Valid values: 301, 302, 303, 307, and 308.

Path String No /test

The path to which requests are redirected.

The path must be 1 to 128 characters in length and can contain letters, digits, asterisks (*), question marks (?), and the following special characters: $ - _ . + / & ~ @ :. The path cannot contain the following special characters: " % # ; ! ( ) [ ] ^ , ". The path must start with a forward slash (/). This value is case-sensitive.

Port String No 10

The port to which requests are redirected.

Valid values: 1 to 63335.

Protocol String No HTTP

The redirect protocol.

Valid values: HTTP and HTTPS.

Note HTTPS listeners do not support HTTPS to HTTP redirection.
Query String No quert

The query string of the URL to which requests are redirected.

The query string must be 1 to 128 characters in length, and can contain printable characters, excluding uppercase letters and the following special characters: # [ ] { } \ | < > &.

RewriteConfig Object No

The configuration of the rewrite action.

Host String No www.example.com

The hostname to which requests are forwarded.

Limits:

  • The hostname must be 3 to 128 characters in length, and can contain lowercase letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).
  • The hostname must contain at least one period (.) but cannot start or end with a period (.).
  • The rightmost domain label can contain only letters, asterisks (*), and question marks (?), and cannot contain digits or hyphens (-).
  • The domain labels cannot start or end with hyphens (-). Asterisks (*) and question marks (?) can appear anywhere in a domain label.
Path String No /tsdf

The path to which requests are forwarded.

The path must be 1 to 128 characters in length and can contain letters, digits, asterisks (*), question marks (?), and the following special characters: $ - _ . + / & ~ @ :. The path cannot contain the following special characters: " % # ; ! ( ) [ ] ^ , ". The path must start with a forward slash (/). This value is case-sensitive.

Query String No quedsa

The query string of the URL to which requests are forwarded.

The query string must be 1 to 128 characters in length, and can contain printable characters, excluding uppercase letters and the following special characters: # [ ] { } \ | < > &.

Type String Yes ForwardGroup

The action. Valid values:

  • ForwardGroup: forwards a request to multiple vServer groups.
  • Redirect: redirects a request.
  • FixedResponse: returns a custom response.
  • Rewrite: rewrites a request.
  • InsertHeader: inserts a header.
  • RemoveHeaderConfig: deletes a header.
  • TrafficLimitConfig: throttles network traffic.
  • TrafficMirrorConfig: mirrors network traffic.

You can specify the last action and the actions that you want to perform before the last action:

  • FinalType: the last action to be performed in a forwarding rule. Each forwarding rule can contain only one FinalType action. You can specify a ForwardGroup, Redirect, or FixedResponse action as the FinalType action.
  • ExtType: the action to be performed before the FinalType action. A forwarding rule can contain one or more ExtType actions. To specify this parameter, you must also specify FinalType. You can specify multiple InsertHeader actions or one Rewrite action.
TrafficLimitConfig Object No

The action to throttle traffic.

QPS Integer No 2

The number of queries per second. Valid values: 1 to 100000.

TrafficMirrorConfig Object No

The action to mirror traffic.

TargetType String No ForwardGroupMirror

The type of destination to which network traffic is mirrored. Valid values:

  • ForwardGroupMirror: a server group
  • SlsMirror: Log Service
MirrorGroupConfig Object No

The list of server groups to which network traffic is mirrored.

ServerGroupTuples Array No

The server group to which network traffic is mirrored.

ServerGroupId String No srg-00mkgijak0w4qgz9****

The ID of the server group.

RemoveHeaderConfig Object No

The action to remove an HTTP header.

Key String No Port

The key of the header.

  • The key must be 1 to 40 characters in length.
  • It can contain lowercase letters, digits, hyphens (-), and underscores (_).
  • You cannot specify Cookie or Host.
RuleConditions Array No

The match conditions of the forwarding rule.

CookieConfig Object No

The match conditions for cookies.

Values Array No

The list of key-value pairs of cookies.

Key String No test

The key of the cookie. The key must be 1 to 100 characters in length, and can contain printable characters such as lowercase letters, asterisks (*), and question marks (?). However, the key cannot contain uppercase letters, space characters, or the following special characters: # [ ] { } \ | < > &.

Value String No test

The value of the cookie. The value must be 1 to 128 characters in length, and can contain printable characters such as lowercase letters, asterisks (*), and question marks (?). However, the value cannot contain uppercase letters, space characters, or the following special characters: # [ ] { } \ | < > &.

HeaderConfig Object No

The match conditions for HTTP headers.

Key String No Port

The key of the header. The key must be 1 to 40 characters in length. It can contain lowercase letters, digits, hyphens (-), and underscores (_). You cannot specify Cookie or Host.

Values Array of String No 5006

The value of the header. The value must be 1 to 128 characters in length. It can contain printable characters whose ASCII values are greater than or equal to 32 and smaller than 127. For example, lowercase letters, asterisks (*), and question marks (?). The value cannot start or end with a space character.

HostConfig Object No

The match conditions for hostnames.

Values Array of String No www.example.com

The hostnames.

Limits:

  • The hostname must be 3 to 128 characters in length, and can contain lowercase letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).
  • The hostname must contain at least one period (.) but cannot start or end with a period (.).
  • The rightmost domain label can contain only letters, asterisks (*), and question marks (?), and cannot contain digits or hyphens (-).
  • The domain labels cannot start or end with hyphens (-). Asterisks (*) and question marks (?) can appear anywhere in a domain label.
MethodConfig Object No

The match conditions for HTTP request methods.

Values Array of String No PUT

The request methods.

Valid values: HEAD, GET, POST, OPTIONS, PUT, PATCH, and DELETE.

PathConfig Object No

The match conditions for query strings.

Values Array of String No /test

The path.

The path must be 1 to 128 characters in length and can contain letters, digits, asterisks (*), question marks (?), and the following special characters: $ - _ . + / & ~ @ :. The path cannot contain the following special characters: " % # ; ! ( ) [ ] ^ , ". The path must start with a forward slash (/). This value is case-sensitive.

QueryStringConfig Object No

The match conditions for query strings.

Values Array No

The key-value pairs of query strings that are used as match conditions.

Key String No test

The key of the query string.

The key must be 1 to 100 characters in length, and can contain printable characters such as lowercase letters, asterisks (*), and question marks (?). However, the key cannot contain uppercase letters, space characters, or the following special characters: # [ ] { } \ | < > &.

Value String No test

The value of the query string.

The value must be 1 to 128 characters in length, and can contain printable characters such as lowercase letters, asterisks (*), and question marks (?). However, uppercase letters, space characters, and the following special characters are not supported: # [ ] { } \ | < > &.

ResponseHeaderConfig Object No

The configuration of the HTTP response header.

Key String No test

The key of the header.

  • The key must be 1 to 40 characters in length.
  • It can contain lowercase letters, digits, hyphens (-), and underscores (_).
  • You cannot specify Cookie or Host.
Values Array of String No 5006

The value of the header.

  • The value must be 1 to 128 characters in length.
  • It can contain printable characters whose ASCII values are greater than or equal to 32 and smaller than 127. For example, lowercase letters, asterisks (*), and question marks (?).
  • The value cannot start or end with a space character.
ResponseStatusCodeConfig Object No

The match conditions for response status codes. This parameter is required and takes effect when Type is set to ResponseStatusCode.

Values Array of String No 301

The response status codes. Valid values: 100 to 599.

Type String No ForwardGroup

The type of the action. Valid values:

  • ForwardGroup: forwards a request to multiple vServer groups.
  • Redirect: redirects a request.
  • FixedResponse: returns a custom response.
  • Rewrite: rewrites a request.
  • InsertHeader: adds a header to a request.
  • RemoveHeaderConfig: deletes a header.
  • TrafficLimitConfig: throttles network traffic.
  • TrafficMirrorConfig: mirrors network traffic.

You can specify the last action and the actions that you want to perform before the last action:

  • FinalType: the last action to be performed in a forwarding rule. Each forwarding rule can contain only one FinalType action. You can specify a ForwardGroup, Redirect, or FixedResponse action as the FinalType action.
  • ExtType: the action to be performed before the FinalType action. A forwarding rule can contain one or more ExtType actions. To specify this parameter, you must also specify FinalType. You can specify multiple InsertHeader actions or one Rewrite action.
SourceIpConfig Object No

The source IP address based on which user traffic is matched.

Values Array of String No 192.168.0.1/32

The IP addresses or CIDR blocks.

Each forwarding rule supports at most five IP addresses or CIDR blocks.

RuleId String Yes rule-cxjh7vazn2jpnl****

The ID of the forwarding rule.

DryRun Boolean No false

Specifies whether to only precheck this request. Valid values:

  • true: prechecks the request without creating the resource. The system prechecks the required parameters, request syntax, and limits. If the request fails to pass the precheck, an error message is returned. If the request passes the precheck, the DryRunOperation error code is returned.
  • false (default): prechecks the request. If the request passes the check, the system returns an HTTP 2xx status code and performs the operation.

Response parameters

Parameter Type Example Description
RequestId String 365F4154-92F6-4AE4-92F8-7FF34B540710

The ID of the request.

JobId String 72dcd26b-f12d-4c27-b3af-18f6aed5****

The ID of the asynchronous task.

Examples

Sample requests

http(s)://[Endpoint]/?Action=UpdateRulesAttribute
&ClientToken=123e4567-e89b-12d3-a456-426655440000
&Rules=[{"Priority":10,"RuleName":"rule-instance-test","RuleActions":[{"FixedResponseConfig":{"Content":"dssacav","ContentType":"text/plain","HttpCode":"200"},"ForwardGroupConfig":{"ServerGroupTuples":[{"ServerGroupId":"sg-atstuj3rtoptyui****","Weight":2}],"ServerGroupStickySession":{"Enabled":false,"Timeout":2}},"InsertHeaderConfig":{"CoverEnabled":false,"Key":"test","Value":"UserDefined","ValueType":"UserDefined"},"Order":1,"RedirectConfig":{"Host":"www.example.com","HttpCode":"301","Path":"/test","Port":"10","Protocol":"HTTP","Query":"quert"},"RewriteConfig":{"Host":"www.example.com","Path":"/tsdf","Query":"quedsa"},"Type":"Host","TrafficLimitConfig":{"QPS":2},"TrafficMirrorConfig":{"TargetType":"ForwardGroupMirror","MirrorGroupConfig":{"ServerGroupTuples":[{"ServerGroupId":"srg-00mkgijak0w4qgz9****"}]}},"RemoveHeaderConfig":{"Key":"Port"}}],"RuleConditions":[{"CookieConfig":{"Values":[{"Key":"test","Value":"test"}]},"HeaderConfig":{"Key":"Port","Values":["5006"]},"HostConfig":{"Values":["www.example.com"]},"MethodConfig":{"Values":["PUT"]},"PathConfig":{"Values":["/test"]},"QueryStringConfig":{"Values":[{"Key":"test","Value":"test"}]},"ResponseHeaderConfig":{"Key":"test","Values":["5006"]},"ResponseStatusCodeConfig":{"Values":["301"]},"Type":"ForwardGroup","SourceIpConfig":{"Values":["192.168.0.0/32"]}}],"RuleId":"rule-cxjh7vazn2jpnl****"}]
&DryRun=false
&Common request parameters

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<UpdateRulesAttributeResponse>
    <RequestId>365F4154-92F6-4AE4-92F8-7FF34B540710</RequestId>
    <JobId>72dcd26b-f12d-4c27-b3af-18f6aed5****</JobId>
</UpdateRulesAttributeResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "365F4154-92F6-4AE4-92F8-7FF34B540710",
  "JobId" : "72dcd26b-f12d-4c27-b3af-18f6aed5****"
}

Error codes

HttpCode Error code Error message Description
400 OperationDenied.IpGroupCanNotUsedForMirrorAction The operation is not allowed because of %s. The error message returned because the operation is not allowed due to %s.
400 IncorrectStatus.Rule The status of %s [%s] is incorrect. The error message returned because the status of the specified resource %s [%s] is invalid.
400 OperationDenied.SameGroupForForwardAndMirrorAction The operation is not allowed because of %s. The error message returned because the operation is not allowed due to %s.
400 OperationDenied.GRPCServerGroup The operation is not allowed because of %s. The error message returned because the operation is not allowed due to %s.
400 Conflict.Priority There is already %s having the same configuration with %s. The error message returned because an existing %s has the same configuration.
400 ResourceQuotaExceeded.ServerGroupAttachedNum The quota of %s is exceeded for resource %s, usage %s/%s. The error message returned because the quota %s of the specified resource %s is exhausted. The current usage is %s.
400 ResourceQuotaExceeded.LoadBalancerServersNum The quota of %s is exceeded for resource %s, usage %s/%s. The error message returned because the quota %s of the specified resource %s is exhausted. The current usage is %s.
400 ResourceQuotaExceeded.ServerAddedNum The quota of %s is exceeded for resource %s, usage %s/%s. The error message returned because the quota %s of the specified resource %s is exhausted. The current usage is %s.
400 QuotaExceeded.RuleWildcardsNum The quota of %s is exceeded, usage %s/%s. The error message returned because the usage %s has exceeded the quota %s.
400 QuotaExceeded.RuleMatchEvaluationsNum The quota of %s is exceeded, usage %s/%s. The error message returned because the usage %s has exceeded the quota %s.
400 QuotaExceeded.RuleActionsNum The quota of %s is exceeded, usage %s/%s. The error message returned because the usage %s has exceeded the quota %s.
400 Mismatch.Protocol The %s is mismatched for %s and %s. The error message returned because %s does not correspond to %s and %s.
400 Mismatch.VpcId The %s is mismatched for %s and %s. The error message returned because %s does not correspond to %s and %s.
400 OperationDenied.ServiceManagedResource The operation is not allowed because the current resource of %s is managed resource. The error message returned because the specified resource %s is a hosted resource and the operation is not allowed.
400 OperationDenied.ListenerIdInconsistent The operation is not allowed because of ListenerIdInconsistent. The error message returned because the specified forwarding rule belongs to a different listener and the operation is not allowed.
404 ResourceNotFound.Rule The specified resource %s is not found. The error message returned because the specified resource %s does not exist.
404 ResourceNotFound.ServerGroup The specified resource %s is not found. The error message returned because the specified resource %s does not exist.

For a list of error codes, visit the API Error Center.