應用上游
建立上游
URI
POST /admin-api/applications/http/{app-id}/clusters
請求示例
Shell
curl 'http://{admin-site}/admin-api/applications/http/1/clusters' \
-H 'Content-Type: application/json;charset=UTF-8' \
--data-raw '{
"nodes":[
{
"netns":"", // 網路
"port":80,
"weight":1, // 轉發權重
"status":1, // 1: 開啟 2: 關閉
"name":"",
"use_proxy_host":false, // 使用代理主機/請求主機作為上游地址。
"ip":"127.0.0.1", // 支援ip和domain
"domain":null // 支援ip和domain
}
],
"name":"openresty", // 上游名字
"ssl":false, // 是否支援ssl協議
"disable_ssl_verify":false, // 是否檢查上游的ssl證書, ssl為true時生效
"checker":{
"use_tcp":false, // 使用 TCP 檢查模式
"http_req_uri":"/status", // HTTP 請求 URI
"http_req_host":"www.openresty.com", HTTP 請求主機
"user_agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0", // 使用者代理
"http_ver":"1.0", // HTTP 版本
"interval":3, // 間隔
"interval_unit":"sec", // 間隔時間單位, 只支援 sec
"timeout":1,
"timeout_unit":"sec", // 超時時間單位, 只支援 sec
"fall":3, // 不健康閾值
"rise":2, // 健康閾值
"valid_statuses":[ // 有效狀態
200,
302
],
"concurrency":5, // 最大併發數
"report_interval":3, // 上報間隔
"report_interval_unit":"min" // 上報間隔單位, 支援 sec, min, hour
},
"enable_checker":true // 開啟健康檢查
}'
響應示例
Status: 200 OK
{
"data":{
"id":4
},
"status":0
}
修改上游資訊
URI
POST /admin-api/applications/http/{app-id}/clusters/{cluster-id}
請求示例
Shell
curl 'http://{admin-site}/admin-api/applications/http/1/clusters/4' \
-X 'PUT' \
-H 'Content-Type: application/json;charset=UTF-8' \
--data-raw '{
"ssl":false,
"creator":1,
"_created_unix":1615449424.7811,
"_modified_unix":1615450307.0989,
"nodes":[
{
"_modified_unix":1615450307.0989,
"id":4,
"_created_unix":1615449424.7811,
"netns":"test",
"status":1,
"use_proxy_host":false,
"name":"localhost.localdomain",
"port":80,
"ip":"127.0.0.1",
"weight":1
}
],
"id":4,
"disable_ssl_verify":false,
"name":"openresty",
"health":{
"success":0,
"fails":0,
"total":0,
"on":0,
"off":0
},
"checker":{
"fall":3,
"http_req_host":"www.openresty.com",
"http_ver":"1.0",
"http_req_uri":"/status",
"interval":3,
"user_agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0",
"interval_unit":"sec",
"valid_statuses":[
200,
302
],
"report_interval":3,
"timeout":2,
"report_interval_unit":"min",
"use_tcp":false,
"rise":2,
"concurrency":5,
"timeout_unit":"sec"
},
"enable_checker":true
}'
響應示例
Status: 200 OK
{
"data":{
"id":4
},
"status":0
}
獲取上游列表
URI
GET /admin-api/applications/http/{app-id}/clusters
URI引數
page
type: integer
required: no
description: 第幾頁 (default 1)
page_size
type: integer
required: no
description: 每頁大小 (default 20)
detail
type: integer
is_necessary: no
description: 傳任意值顯示詳細資訊,不傳顯示簡略資訊
請求示例
Shell
curl 'https://{admin-site}/admin-api/applications/http/3/clusters?page=2&page_size=2&detail=1'
響應示例
Status: 200 OK
{
"data":{
"meta":{
"count":1
},
"data":[
{
"ssl":false,
"creator":1,
"_created_unix":1615449424.7811,
"_modified_unix":1615450307.0989,
"nodes":[
{
"_modified_unix":1615450307.0989,
"id":4,
"_created_unix":1615449424.7811,
"netns":"test",
"status":1,
"use_proxy_host":false,
"name":"localhost.localdomain",
"port":80,
"ip":"127.0.0.1",
"weight":1
}
],
"id":4,
"checker":{
"fall":3,
"http_req_host":"openresty.com",
"http_ver":"1.0",
"http_req_uri":"/status",
"interval":3,
"user_agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0",
"interval_unit":"sec",
"valid_statuses":[
200,
302
],
"report_interval":3,
"timeout":1,
"report_interval_unit":"min",
"use_tcp":false,
"rise":2,
"concurrency":5
},
"disable_ssl_verify":false,
"name":"openresty",
"enable_checker":true
}
]
},
"status":0
}
刪除上游
URI
DELETE /admin-api/applications/http/{app-id}/clusters/{cluster-id}
請求示例
Shell
curl 'http://{admin-site}/admin-api/applications/http/1/clusters/4' -X 'DELETE'
響應示例
Status: 200 OK
{
"status":0
}