10. 负载均衡(upstream)接口

10.1. 获取upstream分页列表

Type: GET

Content-Type: application/x-www-form-urlencoded;charset=UTF-8

Description: 获取upstream分页列表

Query-parameters:

Parameter Type Description Required Since

current

int32

当前页数(从1开始)

true

-

limit

int32

每页数量(默认为10)

true

-

keywords

string

查询关键字

false

-

Request-example:

curl -X GET -i /api/upstream/getPage?current=1&limit=10&keywords=

Response-fields:

Field Type Description Since

success

boolean

请求结果

-

status

string

请求状态 200:请求成功 401:token无效 500:服务器错误

-

msg

string

错误信息

-

obj

object

返回内容

-

└─count

int64

总记录数

-

└─curr

int32

起始页(从1开始)

-

└─limit

int32

每页记录数

-

└─records

array

列表内容

-

     └─any object

object

any object.

-

Response-example:

{
  "success": true,
  "status": "",
  "msg": "",
  "obj": {
    "count": 0,
    "curr": 0,
    "limit": 0,
    "records": [
      {
        "id": "",
        "name": "",
        "tactics": "",
        "proxyType": 0,
        "monitor": 0,
        "descr": ""
      }
    ]
  }
}

10.2. 添加或编辑upstream

Type: GET

Content-Type: application/x-www-form-urlencoded;charset=UTF-8

Description: 添加或编辑upstream

Query-parameters:

Parameter Type Description Required Since

id

string

主键

false

-

name

string

负载均衡名称

false

-

tactics

string

负载策略: '':无(默认) 'sticky':会话保持 'ip_hash':ip绑定 'least_conn':最少连接
'least_time':最短时间

false

-

proxyType

int32

代理类型 0:http(默认) 1:tcp/udp

false

-

monitor

int32

监控邮件通知 0:否(默认) 1:是

false

-

descr

string

描述

false

-

Request-example:

curl -X GET -i /api/upstream/insertOrUpdate?proxyType=0&monitor=0&name=&descr=&id=&tactics=

Response-fields:

Field Type Description Since

success

boolean

请求结果

-

status

string

请求状态 200:请求成功 401:token无效 500:服务器错误

-

msg

string

错误信息

-

obj

object

返回内容

-

Response-example:

{
  "success": true,
  "status": "",
  "msg": "",
  "obj": {}
}

10.3. 删除upstream

Type: GET

Content-Type: application/x-www-form-urlencoded;charset=UTF-8

Description: 删除upstream

Query-parameters:

Parameter Type Description Required Since

id

string

upstream的id

false

-

Request-example:

curl -X GET -i /api/upstream/delete?id=

Response-fields:

Field Type Description Since

success

boolean

请求结果

-

status

string

请求状态 200:请求成功 401:token无效 500:服务器错误

-

msg

string

错误信息

-

obj

object

返回内容

-

Response-example:

{
  "success": true,
  "status": "",
  "msg": "",
  "obj": {}
}

10.4. 根据upstreamId获取server列表

Type: GET

Content-Type: application/x-www-form-urlencoded;charset=UTF-8

Description: 根据upstreamId获取server列表

Query-parameters:

Parameter Type Description Required Since

upstreamId

string

upstream的id

false

-

Request-example:

curl -X GET -i /api/upstream/getServerByUpstreamId?upstreamId=

Response-fields:

Field Type Description Since

success

boolean

请求结果

-

status

string

请求状态 200:请求成功 401:token无效 500:服务器错误

-

msg

string

错误信息

-

obj

array

返回内容

-

└─id

string

主键

-

└─upstreamId

string

负载均衡upstream的id

-

└─server

string

负载节点ip (例:10.10.10.1)

-

└─port

int32

负载节点端口 (例:8080)

-

└─weight

int32

负载节点权重

-

└─failTimeout

int32

失败等待时间,秒

-

└─maxFails

int32

最大失败次数

-

└─maxConns

int32

最大连接数

-

└─status

string

状态策略 'none':无(默认) 'down':停用 'backup':备用

-

└─param

string

其他参数

-

Response-example:

{
  "success": true,
  "status": "",
  "msg": "",
  "obj": [
    {
      "id": "",
      "upstreamId": "",
      "server": "",
      "port": 0,
      "weight": 0,
      "failTimeout": 0,
      "maxFails": 0,
      "maxConns": 0,
      "status": "",
      "param": ""
    }
  ]
}

10.5. 添加或编辑server

Type: GET

Content-Type: application/x-www-form-urlencoded;charset=UTF-8

Description: 添加或编辑server

Query-parameters:

Parameter Type Description Required Since

id

string

主键

false

-

upstreamId

string

负载均衡upstream的id

false

-

server

string

负载节点ip (例:10.10.10.1)

false

-

port

int32

负载节点端口 (例:8080)

false

-

weight

int32

负载节点权重

false

-

failTimeout

int32

失败等待时间,秒

false

-

maxFails

int32

最大失败次数

false

-

maxConns

int32

最大连接数

false

-

status

string

状态策略 'none':无(默认) 'down':停用 'backup':备用

false

-

param

string

其他参数

false

-

Request-example:

curl -X GET -i /api/upstream/insertOrUpdateServer?port=0&weight=0&failTimeout=0&maxFails=0&maxConns=0¶m=&status=&id=&server=&upstreamId=

Response-fields:

Field Type Description Since

success

boolean

请求结果

-

status

string

请求状态 200:请求成功 401:token无效 500:服务器错误

-

msg

string

错误信息

-

obj

object

返回内容

-

Response-example:

{
  "success": true,
  "status": "",
  "msg": "",
  "obj": {}
}