頁面規則

新建規則

URI

POST /admin-api/applications/http/21/phases/rewrite/rules

JSON body

  • actions

    type: array

    required: no

    description: 動作

  • conditions

    type: array

    required: no

    description: 條件

  • conditions.number

    type: integer

    required: yes

    description: 數量

  • conditions.operator

    type: object

    required: yes

    description: 操作

  • conditions.operator.name

    type: string

    required: yes

    description: 操作名稱

  • conditions.values

    type: array

    required: yes

    description: 值

  • conditions.values.type

    type: string

    required: yes

    description: 型別

  • conditions.values.val

    type: string

    required: yes

    description: 值

  • conditions.variable

    type: object

    required: yes

    description: 變數

  • conditions.variable.name

    type: string

    required: yes

    description: 變數名稱

  • content

    type: string

    required: no

    description: 內容

  • last

    type: boolean

    required: yes

    description: 新增到最後

  • order

    type: integer

    required: yes

    description: 順序

  • proxy

    type: object

    required: no

    description: 代理

  • proxy.backup_upstream

    type: array

    required: no

    description: 備份後端

  • proxy.balancer

    type: object

    required: no

    description: 分流

  • proxy.balancer.algorithm

    type: string

    required: no

    description: 分流演算法

  • proxy.balancer.variables

    type: array

    required: no

    description: 變數

  • proxy.connect_timeout

    type: integer

    required: yes

    description: 超時時間

  • proxy.connect_timeout_unit

    type: integer

    required: yes

    description: 超時單位

  • proxy.layer_policy

    type: object

    required: yes

    description: 層策略

  • proxy.read_timeout

    type: integer

    required: yes

    description: 讀超時時間

  • proxy.read_timeout_unit

    type: integer

    required: yes

    description: 讀超時單位

  • proxy.retries

    type: integer

    required: yes

    description: 重試次數

  • proxy.retry_condition

    type: array

    required: yes

    description: 重試條件

  • proxy.send_timeout

    type: integer

    required: yes

    description: 傳送超時時間

  • proxy.send_timeout_unit

    type: integer

    required: yes

    description: 傳送超時時間

  • proxy.sticky

    type:

    required: no

    description:

  • proxy.upstream

    type: object

    required: yes

    description: 上游

  • proxy.upstream.cluster

    type: integer

    required: yes

    description: 上游id

  • proxy.upstream.global_cluster

    type: integer

    required: no

    description:

  • proxy.upstream.weight

    type: integer

    required: yes

    description: 權重

  • proxy.upstream.upstream

    type:

    required: yes

    description:

  • proxy.upstream.upstream_el_code

    type: string

    required: yes

    description:

  • proxy.upstream.useSameBalancingPolicy

    type: boolean

    required: yes

    description:

  • waf

    type: object

    required: no

    description:

請求示例

Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  'http://admin-site/admin-api/applications/http/21/phases/rewrite/rules'
  -d '{"actions":[],"conditions":[{"variable":{"name":"uri"},"operator":{"name":"prefix"},"values":[{"type":"str","val":"/test"}],"number":1}],"waf":null,"proxy":{"upstream":[{"cluster":27,"global_cluster":null,"weight":1,"upstream":null}],"backup_upstream":[],"upstream_el_code":"","balancer":{"algorithm":"roundrobin","variables":[]},"useSameBalancingPolicy":true,"sticky":null,"retry_condition":["error","timeout","invalid_header","http_500","http_502","http_504"],"connect_timeout":60,"connect_timeout_unit":"s","send_timeout":60,"send_timeout_unit":"s","read_timeout":60,"read_timeout_unit":"s","retries":1,"layer_policy":null},"cache":null,"content":null,"last":true,"comment":"","order":2}'

響應示例

Status: 200 OK
{
    "data": {
        "id": 12
    },
    "status": 0
}

獲取規則列表

URI

GET /admin-api/applications/http/21/phases/rewrite/rules

URI引數

  • detail

    type: integer

    required: no

    description: 是否返回詳細資訊

請求示例

Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  'http://admin-site/admin-api/applications/http/21/phases/rewrite/rules?detail=1'

響應示例

Status: 200 OK
{
    "data": [{
        "top": 0,
        "last": true,
        "id": 9,
        "_created_unix": 1614842323.6072,
        "proxy": {
            "send_timeout": 60,
            "connect_timeout_unit": "s",
            "upstream": [{
                "weight": 1,
                "id": 10,
                "cluster": 24
            }],
            "retries": 1,
            "balancer": {
                "algorithm": "roundrobin"
            },
            "retry_condition": ["error", "timeout", "invalid_header", "http_500", "http_502", "http_504"],
            "read_timeout_unit": "s",
            "connect_timeout": 60,
            "send_timeout_unit": "s",
            "read_timeout": 60,
            "upstream_el_code": ""
        },
        "_modified_unix": 1614842323.6072,
        "order": 1,
        "conditions": [{
            "operator": {
                "name": "prefix"
            },
            "variable": {
                "name": "uri"
            },
            "id": 8,
            "values": [{
                "type": "str",
                "id": 8,
                "val": "\/testpath"
            }]
        }],
        "comment": "",
        "enable_rule": true
    }],
    "status": 0
}