# Describe the forwarding rules of application load balancing - DescribeRules

## Overview

Describe a specified forwarding rule or all forwarding rules under an application-type load balancer listener

 > 💡 The Weight of the default rule stays in sync with the actual Weight of the target.




## Definition

### Public Parameters

| Parameter Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Action**     | string  | Corresponding API command name, the current API is `DescribeRules`.                      | **Yes** |
| **PublicKey**  | string  | The user's public key can be obtained from [Console](https://console.scloudsg.com/uaccount/api_manage)                                             | **Yes** |
| **Signature**  | string  | User signature generated based on public key and API command, see [Signature Algorithm](/docs/api/summary/signature.md)  | **Yes** |

### Request Parameters

| Parameter Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Region** | string | Region. See [List of Regions and Availability Zones](/docs/api/summary/regionlist) |**Yes**|
| **ProjectId** | string | Project ID. If not filled in, the default project is used, sub-accounts must be filled in. Please refer to the [GetProjectList interface](/docs/api/summary/get_project_list). |**Yes**|
| **LoadBalancerId** | string | ID of the Application Load Balancer Instance |**Yes**|
| **ListenerId** | string | Listener's ID |**Yes**|
| **RuleId** | string | The ID of the application load balancing forwarding rule. If RuleId is specified, only this rule will be described. |No|

### Response Field

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **RetCode** | int | Return status code. If it is 0, it means successful return. If it is not 0, it means failure. |**Yes**|
| **Action** | string | Operation command name. |**Yes**|
| **Message** | string | Returns an error message, providing detailed description when `RetCode` is non-zero. |No|
| **Rules** | array[[*Rule*](#rule)] | Forwarding Rule Information |**Yes**|

#### Data Model


#### Rule

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **RuleId** | string | ID of the forwarding rule |No|
| **RuleConditions** | array[[*RuleCondition*](#rulecondition)] | Forwarding rule matching conditions. See RuleCondition for specific structure. |No|
| **RuleActions** | array[[*RuleAction*](#ruleaction)] | Forwarding action. For specific rules, see RuleAction. |No|
| **IsDefault** | boolean | Is it the default forwarding rule? |No|
| **Pass** | boolean | When the service node for forwarding is empty, should the rule be ignored? |No|

#### RuleCondition

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Type** | string | Match condition type. Limited enumeration values: Host, Path |**Yes**|
| **HostConfig** | [*HostConfigSet*](#hostconfigset) | Domain-related configuration. Required when Type is Host. See HostConfigSet for specific structure. |No|
| **PathConfig** | [*PathConfigSet*](#pathconfigset) | Configuration related to the path. Required when Type is Path. For detailed structure, see PathConfigSet. |No|

#### RuleAction

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Type** | string | Action type. Limited enumeration values: Forward, "InsertHeader", "Cors", "FixedResponse", "RemoveHeader"  |**Yes**|
| **ForwardConfig** | [*ForwardConfigSet*](#forwardconfigset) | Forward service node related configuration, corresponding to type value: "Forward". For specific structure, see ForwardConfigSet. |No|
| **FixedResponseConfig** | [*FixedResponseConfigSet*](#fixedresponseconfigset) | Static return related configuration, corresponding to type value: "FixedResponse". For specific structure, see FixedResponseConfigSet |No|
| **InsertHeaderConfig** | [*InsertHeaderConfigSet*](#insertheaderconfigset) | Insert header-related configuration, corresponding to the type value: "InsertHeader". For the specific structure, see InsertHeaderConfigSet. |No|
| **CorsConfig** | [*CorsConfigSet*](#corsconfigset) | Configuration related to cross-domain, corresponding to type value: "Cors". For specific structure, see CorsConfigSet. |No|
| **RemoveHeaderConfig** | [*RemoveHeaderConfigSet*](#removeheaderconfigset) | Delete header-related configuration, corresponding type value: "RemoveHeader". For specific structure, see RemoveHeaderConfigSet |No|
| **Order** | int | The execution order of forwarding rule actions ranges from 1 to 1000, with actions executed from smallest to largest value. The value cannot be empty or duplicated.<br /><br />Forward and FixedResponse types of actions do not consider Order and are executed last. |No|

#### ForwardConfigSet

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Targets** | array[[*ForwardTargetSet*](#forwardtargetset)] | The backend service nodes to be forwarded. It is limited to the service node pool of the listener; the array length can be 0. See ForwardTargetSet for detailed structure. |**Yes**|

#### FixedResponseConfigSet

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **HttpCode** | int | Returned HTTP response codes, only supporting 2xx, 4xx, 5xx numbers, where x is any digit. |**Yes**|
| **Content** | string | Returned fixed content. Supports storing up to 1 KB, only supports printable characters within the ASCII code range ch >= 32 && ch < 127, excluding $. |No|

#### InsertHeaderConfigSet

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Key** | string | The inserted header field name must be 1 to 40 characters long and can include uppercase and lowercase letters a-z, numbers, underscores (_), and hyphens (-). The header field name cannot be reused in InsertHeader.<br /><br />The header field cannot use the following (case insensitive):<br /><br />x-real-ip, x-forwarded-for, x-forwarded-proto, x-forwarded-srcport, ucloud-alb-trace, connection, upgrade, content-length, transfer-encoding, keep-alive, te, host, cookie, remoteip, authority. |**Yes**|
| **Value** | string | Inserted header field content.<br /><br />When ValueType is SystemDefined, the values are as follows:<br />ClientSrcPort: Client port.<br />ClientSrcIp: Client IP address.<br />Protocol: Protocol of the client's request (HTTP or HTTPS).<br />RuleID: ID of the forwarding rule hit by the client's request.<br />ALBID: ALB ID.<br />ALBPort: ALB port.<br /><br />When ValueType is UserDefined:<br /><br />You can customize the header field content, with a length limit of 1\~128 characters, supporting printable characters in the ASCII range ch >= 32 && ch < 127, excluding $.<br /><br />When ValueType is ReferenceHeader:<br /><br />You can reference a specific field from the request header, with a length limit of 1\~128 characters, supporting lowercase letters a\~z, numbers, hyphens (-), and underscores (_). |**Yes**|
| **ValueType** | string | Header field content type. Values:<br /><br />UserDefined: User specified.<br /><br />ReferenceHeader: Referencing a field from the user's request header.<br /><br />SystemDefined: System defined. |**Yes**|

#### CorsConfigSet

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **AllowOrigin** | array[string] | Allowed access source list. Supports configuring only one element *, or configuring one or more values.<br /><br />A single value must start with http:// or https://, followed by a correct domain name or a first-level wildcard domain. (Example: http://*.test.abc.example.com)<br />A single value can be without a port or specify a port, with a port range: 1\~65535.<br />Supports up to 5 values. |**Yes**|
| **AllowHeaders** | array[string] | List of Headers allowed for cross-origin. Supports configuration as * or one or more value entries. A single value entry can only contain uppercase and lowercase letters, numbers, and cannot start or end with an underscore (_) or hyphen (-), with a maximum length limit of 32 characters. Supports up to 20 values. |No|
| **ExposeHeaders** | array[string] | List of allowed exposed Headers. Supports configuration as * or one or more value entries. A single value entry can only contain uppercase and lowercase letters, numbers, and cannot start or end with an underscore (_) or hyphen (-), with a maximum length of 32 characters. Supports up to 20 values. |No|
| **AllowMethods** | array[string] | Select the allowed HTTP methods for cross-domain access. Values:<br /><br />GET<br />POST<br />PUT<br />DELETE<br />HEAD<br />OPTIONS<br />PATCH |No|
| **AllowCredentials** | string | Allow carrying credential information. Values:<br /><br />on: Yes.<br />off: No. |No|
| **MaxAge** | int | The maximum cache time for preflight requests in the browser, in seconds.<br /><br />Value range: -1\~172800. |No|

#### RemoveHeaderConfigSet

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Key** | string | The names of the header fields to be deleted, currently only the following default configured fields can be deleted: X-Real-IP, X-Forwarded-For, X-Forwarded-Proto, X-Forwarded-SrcPort |**Yes**|

#### ForwardTargetSet

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Id** | string | Identification ID of the service node |**Yes**|
| **Weight** | int | Weight. Only valid when the load balancing algorithm of the listener is weighted round robin; Value range [1-100], default value is 1. |No|

#### HostConfigSet

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Values** | array[string] | Value. Currently only supports an array length of 1; The value must meet the conditions of the relevant matching method. |**Yes**|
| **MatchMode** | string | Matching method. Limited enumeration values: Regular-Regular, Wildcard-Wildcard domain; Default value: Regular. |No|

#### PathConfigSet

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Values** | array[string] | Value. Currently only supports an array length of 1; The value must meet the conditions of the relevant matching method. |**Yes**|

## Example

### Request Example
    
```
https://api.scloudsg.com/?Action=DescribeRules
&Region=cn-zj
&ProjectId=AONmKvcb
&LoadBalancerId=cCWlIOts
&ListenerId=NmxHLcXL
&RuleId=vNcPniOK
```

### Response Example
    
```json
{
  "Action": "DescribeRulesResponse",
  "RetCode": 0,
  "Rules": [
    {
      "IsDefault": true,
      "Pass": false,
      "RuleActions": [
        {
          "InsertHeaderConfig": {
            "Key": "test1",
            "Value": "ClientSrcPort",
            "ValueType": "SystemDefined"
          },
          "Order": 1,
          "Type": "InsertHeader"
        },
        {
          "InsertHeaderConfig": {
            "Key": "test2",
            "Value": "test2",
            "ValueType": "UserDefined"
          },
          "Order": 2,
          "Type": "InsertHeader"
        },
        {
          "InsertHeaderConfig": {
            "Key": "test3",
            "Value": "test3",
            "ValueType": "UserDefined"
          },
          "Order": 3,
          "Type": "InsertHeader"
        },
        {
          "Order": 4,
          "RemoveHeaderConfig": {
            "Key": "X-Forwarded-Proto"
          },
          "Type": "RemoveHeader"
        },
        {
          "CorsConfig": {
            "AllowCredentials": "on",
            "AllowHeaders": [
              "Origin",
              "Accept",
              "Accept"
            ],
            "AllowMethods": [
              "OPTIONS",
              "HEAD",
              "GET",
              "POST",
              "PUT",
              "PATCH"
            ],
            "AllowOrigin": [
              "http://example.com",
              "http://example.com",
              "https://example.com:123",
              "https://example.com:12313"
            ],
            "ExposeHeaders": [
              "User-Agent",
              "Cache-Control"
            ],
            "MaxAge": -1
          },
          "Order": 5,
          "Type": "Cors"
        },
        {
          "ForwardConfig": {
            "Targets": [
              {
                "Id": "ars-XXXXX",
                "Weight": 1
              }
            ]
          },
          "Type": "Forward"
        }
      ],
      "RuleConditions": [
        {
          "HostConfig": {},
          "PathConfig": {},
          "Type": "cn-zj"
        }
      ],
      "RuleId": "GHOQYSjh"
    }
  ]
}
```





