用於建立一個新的負載平衡器執行個體,支援自訂路由策略、會話保持、監控配置等進階功能。
介面說明
通過此 API,使用者可以根據業務需求配置負載平衡服務,包括但不限於自適應路由、加權輪詢、規則匹配、健全狀態檢查等設定,以實現流量的有效管理和最佳化。
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
調試
授權資訊
請求參數
|
名稱 |
類型 |
必填 |
描述 |
樣本值 |
| Name |
string |
是 |
負載平衡器名稱,需要滿足網域名稱格式校正,並且是網站下的子網域名稱。 |
lb.example.com |
| Enabled |
boolean |
否 |
負載平衡器是否啟用。
枚舉值:
|
true |
| SiteId |
integer |
是 |
網站 ID,可通過調用 ListSites 介面擷取。 |
123456789**** |
| AdaptiveRouting |
object |
否 |
跨位址集區回源配置。 |
true |
| FailoverAcrossPools |
boolean |
否 |
是否跨位址集區回源。
|
true |
| DefaultPools |
array |
是 |
預設位址集區列表。 |
123 |
|
integer |
否 |
預設位址集區 ID,整型。 |
95223818027**** |
|
| FallbackPool |
integer |
是 |
兜底位址集區 ID,當所有其他池不可用時,流量將被導向此處。 |
123 |
| RandomSteering |
object |
否 |
加權輪詢配置,用於控制不同位址集區的流量分配權重。 |
123 |
| DefaultWeight |
integer |
否 |
預設的輪詢權重,用於所有沒有單獨指定權重的位址集區。取值範圍:0-100 之間的整數。 |
50 |
| PoolWeights |
object |
否 |
各後端伺服器池的權重配置,鍵為池 ID,值為權重係數。權重係數表示相對流量分配的比例。 |
|
|
integer |
否 |
單個源位址集區的權重,0-100 的數字,0 表示不往該源位址集區調度流量。 |
50 |
|
| Rules |
array<object> |
否 |
規則資訊。 |
{ "ENAM": [ 12345678**** ], "WNAM": [ 23456789****, 23456789**** ] } |
|
array<object> |
否 |
規則結構體。 |
||
| RuleName |
string |
否 |
規則名稱。添加全域配置的時候不需要設定該參數。 |
rule_1 |
| Rule |
string |
否 |
規則內容,使用條件運算式來匹配使用者請求。添加全域配置的時候不需要設定該參數。存在兩種使用情境:
|
(http.request.method eq "GET" and http.request.version eq "HTTP/1.0") or (ip.geoip.country eq "CN") or (http.host eq "www.example.com") |
| RuleEnable |
string |
否 |
規則開關。添加全域配置的時候不需要設定該參數。取值範圍:
|
on |
| FixedResponse |
object |
否 |
匹配規則後執行響應指定內容。 |
{"content_type": "application/json", "location": "www.example.com", "message_body": "Testing Hello", "status_code": 0} |
| ContentType |
string |
否 |
HTTP Header 中的 Content-Type 欄位。 |
application/octet-stream |
| Location |
string |
否 |
HTTP 返回中的 location 欄位。 |
http://www.example.com/index.html |
| MessageBody |
string |
否 |
響應 body 值。 |
Hello World! |
| StatusCode |
integer |
否 |
響應狀態代碼。 |
200 |
| Overrides |
any |
否 |
匹配規則後修改對應請求改寫的負載平衡配置,配置的欄位,會覆蓋負載平衡器配置裡相應的欄位。 |
{ "adaptive_routing": { "failover_across_pools": true }, "sub_region_pools": { "AL,AT": [ 92298024898****, 92304347804**** ], "BG,BY": [ 92298024898**** ] }, "default_pools": [ 92298024898****, 92304347804**** ], "fallback_pool": 92298024898****, "location_strategy": { "mode": "resolver_ip", "prefer_ecs": "always" }, "random_steering": { "default_weight": 0.3, "pool_weights": { "92298024898****": 0.7, "92304347804****": 0.8 } }, "region_pools": { "CN,SEAS": [ 92298024898****, 92304347804**** ], "SAF,SAS": [ 92304347804**** ] }, "session_affinity": "ip", "steering_policy": "geo", "ttl": 30 } |
| Sequence |
integer |
否 |
規則執行順序,可以不填,不填時以列表順序執行,如果填的話,是大於 0 的整數。數值越大越優先執行。 |
1 |
| Terminates |
boolean |
否 |
是否終止執行後續規則。
|
true |
| SessionAffinity |
string |
否 |
會話保持,取值:
|
ip |
| SteeringPolicy |
string |
是 |
負載平衡策略。
|
order |
| Description |
string |
否 |
負載平衡器的詳細描述資訊,便於管理和識別。 |
測試負載平衡器描述 |
| Ttl |
integer |
否 |
TTL 值,DNS 記錄的存留時間,預設為 30 秒。取值範圍:10-600。 |
300 |
| Monitor |
object |
是 |
監視器配置,用於健全狀態檢查。 |
order |
| Type |
string |
否 |
監視器協議類型,如 HTTP,用於健全狀態檢查,值為 off 時,表示不進行檢查。
|
HTTP |
| Method |
string |
否 |
監視器要求方法,如 |
GET |
| Port |
integer |
否 |
來源站點連接埠。 |
1921 |
| Path |
string |
否 |
監視器檢查路徑,如 |
/health |
| Interval |
integer |
否 |
監視間隔,如 |
60 |
| Timeout |
integer |
否 |
應用健全狀態檢查逾時時間,單位為秒,取值範圍:1-10。 |
5 |
| ExpectedCodes |
string |
否 |
預期狀態代碼,如 |
200 |
| FollowRedirects |
boolean |
否 |
是否跟隨重新導向。
|
true |
| ConsecutiveUp |
integer |
否 |
連續探測多少次成功算成功,如 |
3 |
| ConsecutiveDown |
integer |
否 |
連續探測多少次失敗算失敗,如 |
5 |
| Header |
any |
否 |
探測時所帶頭部資訊,HTTP 頭。 |
{ "host": [ "example1.com", "example2.com" ] } |
| MonitoringRegion |
string |
否 |
探測點所在地區,預設為 Global,
枚舉值:
|
Global |
| SubRegionPools |
any |
否 |
二級 region 對應的位址集區,多個二級 region 共用一批位址集區時,可以多個二級 region,使用逗號拼接作為 key。 |
{"AL,MO": [92298024898****],"CN-SH,CN-SX,CN-SC":[92304347804****,92843536908****]} |
| RegionPools |
any |
否 |
一級 region 對應的位址集區。 |
{ "ENAM": [ 12345678**** ], "WNAM": [ 23456789****, 23456789**** ] } |
返回參數
|
名稱 |
類型 |
描述 |
樣本值 |
|
object |
Schema of Response |
||
| RequestId |
string |
請求 ID。 |
EEEBE525-F576-1196-8DAF-2D70CA3F4D2F |
| Id |
integer |
負載平衡器 ID。 |
99867648760**** |
樣本
正常返回樣本
JSON格式
{
"RequestId": "EEEBE525-F576-1196-8DAF-2D70CA3F4D2F\n",
"Id": 0
}
錯誤碼
|
HTTP status code |
錯誤碼 |
錯誤資訊 |
描述 |
|---|---|---|---|
| 400 | InvalidParameter | The specified parameter is invalid. | 輸入參數規範校正失敗。 |
| 400 | LoadBalancerQuotaCheckFailed | Load balancer enable quota check failed. | 您當前的套餐無法使用負載平衡器相關功能,如需使用,請進行套餐升級。 |
| 400 | LoadBalancerNumberExceedQuotaLimit | The number of load balancers you have added has reached the limit of the plan quota. Please delete the unused load balancers or upgrade the plan and try again. | 您添加的負載平衡器數量已經達到套餐配額限制,請刪除不使用的負載平衡器或者升級套餐後進行重試。 |
| 400 | LoadBalancerRuleQuotaCheckFailed | Your current plan does not support configuring load balancer custom rules, or the load balancer rules you have added exceed the plan quota limit. Please upgrade the plan or delete the rules that are no longer in use and try again. | 您當前的套餐不支援配置負載平衡器自訂規則,或者您已經添加的負載平衡器規則超過套餐配額限制,請升級套餐或者刪除不再使用的規則後重試。 |
| 400 | LoadBalancerPolicyCheckFailed | Your current plan does not support the load balancer scheduling policy. Upgrade the plan and try again. | 您當前的套餐不支援使用該負載平衡器調度策略,請升級套餐後重試。 |
| 400 | LoadBalancerHealthDetectionQuotaCheckFailed | Your current plan does not allow you to configure the load balancer's health detection. Upgrade the plan and try again. | 您當前的套餐不允許配置負載平衡器的健康探測,請升級套餐後重試。 |
| 400 | LoadBalancerHealthDetectionIntervalCheckFailed | The configured load balancer health detection interval exceeds the quota range allowed by the plan. Please revise the interval within the range or upgrade the plan and try again. | 您配置的負載平衡器健康探測時間間隔超出了套餐允許的配額範圍,請訂正為範圍內的間隔或者升級套餐後,進行重試。 |
| 400 | InternalException | Failed to call the service. Try again later or contact technical support. | 調用服務失敗,請稍後重試或聯絡客服諮詢詳情。 |
| 400 | Instance.NotOnline | Your plan is unavailable due to an overdue payment. Complete the payment first. | 您的套餐執行個體因欠費當前處於非上線狀態,請先完成續約操作以繼續使用。 |
| 400 | MonitorExpectedBodyInvalid | Invalid response body. Specify a response body that does not exceed 102,400 characters in length in your custom rule. | 傳入的監視器預期傳回值不正確,長度不能大於102400字元,請您確認傳回值後重試。 |
| 400 | MonitorExpectedCodesInvalid | Invalid expected status code for the probe.Make sure that you specify no more than 10 status codes in the probe settings, and each status code must be 3 to 4 characters in length.Examples: 200, 301, 3xx, 8000, and 88xx. | 傳入的監視器預期返回碼不合法。請注意:返回碼的數量不能超過10個,且每個返回碼的長度應不少於3個字元且不超過4個字元。例如:200、301、3xx、8000、88xx。 |
| 400 | MonitorHeaderInvalid | Invalid request header for the probe. You can add up to 10 request headers, each with 1 to 9 values. The combined length of all headers and values cannot exceed 6,000 characters. You cannot configure the User-Agent header. | 傳入的監視器攜帶的要求標頭非法。請確保要求標頭數量不超過10個,每個要求標頭的值長度在1到10之間,並且不得使用User-Agent要求標頭(該要求標頭保留用於內部特定情境)。此外,所有要求標頭及其值的總長度不得超過6000個字元。請您檢查並修正要求標頭配置後重試。 |
| 400 | MonitorMethodNotSupport | Invalid HTTP method for the probe request. Valid values are GET and HEAD. | 傳入的監視器要求方法不支援,只支援以下方法:GET/HEAD。 |
| 400 | MonitorPathNotSupport | Invalid probe URL path.If you set the probe protocol to HTTP or HTTPS, make sure you specify a probe URL path that does not exceed 1,024 characters in length. | 傳入的監聽路徑不支援。當監聽類型為HTTP或HTTPS時,監聽路徑不可為空,且路徑長度不得超過1024個字元,請您檢查路徑後重試。 |
| 400 | MonitorPortNotSupport | Invalid probe port. Specify a valid port from 1 to 65535 for the probe request. Then, try again. | 傳入的監視器監聽連接埠不支援,連接埠取值範圍:[1-65535],請您確保連接埠在取值範圍內重試。 |
| 400 | MonitorRetriesInvalid | Invalid number of probe retries. Specify an integer from 0 to 5. Then, try again. | 傳入的監視器重試次數參數不支援,支援的重試次數取值範圍為:[0-5],請確保設定的重試次數在此範圍內。 |
| 400 | MonitorTimeoutInvalid | Invalid timeout for the probe. Valid values are 1 to 10. | 傳入的監視器逾時時間超出取值範圍,支援以下範圍:[1-10]。 |
| 400 | MonitorTypeNotSupport | Invalid protocol. Valid values are off, HTTP, HTTPS, TCP, UDP, ICMP Ping, and SMTP. | 傳入的監視器類型不支援,監視器只支援以下類型:off/HTTP/HTTPS/TCP/UDP/ICMP Ping/SMTP。 |
| 400 | OriginPoolNotExist | The specified origin pool does not exist or does not belong to your account or website. Check and try again. | 傳入的源位址集區不存在,或該位址集區不屬於目前使用者和網站,請您確認後重試。 |
| 400 | LoadBalancerNameConflict | The load balancer name or the hostname for the origin pool already exists. Try again with a unique name. | 負載平衡器名稱或源位址集區記錄名已存在,請更換一個唯一的名字重試。 |
| 400 | LockFailed | The system is handling requests you previously submitted. Try again later. | 您有其他請求正在處理中,請稍後再進行重試。 |
| 400 | SourceCircleExist | The host record of the resource to be operated on is already the source station of another resource, or the source station of the current resource has been added as a host record. To avoid loopback, modify the host record or source station and retry. | 當前要操作資源的主機記錄已經是其他資源的來源站點,或者當前資源的來源站點已經被添加為主機記錄,為避免迴環產生,請修改主機記錄或者來源站點後進行重試。 |
| 400 | LoadBalancer.NameInvalid | The name of the Server Load Balancer instance is a valid domain name or belongs to the site. Check that it is correct and try again. | Server Load Balancer執行個體的名稱是合法的網域名稱或屬於網站,請檢查正確後重試。 |
| 400 | CompileRuleError | Rule compilation failed, please check the rule information passed in to ensure that the rule is written according to the syntax described in the document. | 規則編譯失敗,請檢查傳入的規則配置,請參考介面文檔中描述的規則配置格式。 |
| 400 | InstanceNotExist | The instance does not exist. Check whether the specified instance ID is correct or whether the instance belongs to your account. | 執行個體不存在,請檢查提供的執行個體ID是否正確或該執行個體是否屬於您的賬戶。 |
| 403 | QuotaExceeded | The quota is exceeded. | 額度不足 |
| 404 | SiteNotFound | The website does not exist or does not belong to you. | 網站不存在,或者不屬於你。 |
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。