页面规则
新建规则
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
}