在指定監聽下建立轉發規則。
介面說明
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
調試
授權資訊
|
操作 |
存取層級 |
資源類型 |
條件關鍵字 |
關聯操作 |
|
alb:CreateRule |
create |
*LoadBalancer
*ServerGroup
|
無 | 無 |
請求參數
|
名稱 |
類型 |
必填 |
描述 |
樣本值 |
| ListenerId |
string |
是 |
應用型負載平衡執行個體監聽 ID。 |
lsn-l16uo9y****** |
| ClientToken |
string |
否 |
用戶端 Token,用於保證請求的冪等性。 由用戶端產生該參數值,要保證在不同請求間唯一。ClientToken 只支援 ASCII 字元。 說明
若您未指定,則系統自動使用 API 請求的 RequestId 作為 ClientToken 識別碼。每次 API 請求的 RequestId 不一樣。 |
5A2CFF0E-5718-45B5-9D4D-70B****** |
| DryRun |
boolean |
否 |
是否僅預檢此次請求,取值:
|
false |
| Priority |
integer |
是 |
規則優先順序,取值範圍:1~10000。值越小表示優先順序越高。 說明
同一個監聽內規則優先順序必須唯一。 |
10 |
| Direction |
string |
否 |
轉發規則的方向。取值:
說明
基礎版的 ALB 執行個體不支援 Response 類型。 |
Request |
| RuleActions |
array<object> |
是 |
轉發規則動作清單。 |
|
|
array<object> |
是 |
規則動作清單。 |
||
| FixedResponseConfig |
object |
否 |
固定回應內容配置。 |
|
| Content |
string |
否 |
返回的固定內容。最大支援儲存 1 KB,只支援 ASCII 字元。 |
dssacav |
| ContentType |
string |
否 |
返回固定內容的格式。 取值:text/plain、text/css、text/html、application/javascript 或 application/json。 |
text/plain |
| HttpCode |
string |
否 |
返回的 HTTP 回應碼,僅支援 2xx、4xx、5xx 數字型字串,x 為任意數字。 |
200 |
| ForwardGroupConfig |
object |
否 |
轉發到的目的伺服器群組清單。一條轉發規則中最多支援新增 5 個目的伺服器群組。 |
|
| ServerGroupTuples |
array<object> |
否 |
轉發到的目的伺服器群組清單。一條轉發規則中最多支援新增 5 個目的伺服器群組。 |
|
|
object |
否 |
轉發到的目的伺服器群組結構。 |
||
| ServerGroupId |
string |
否 |
轉寄到的目的伺服器組。 |
sgp-k86c1ov501id6p**** |
| Weight |
integer |
否 |
權重。取值越大,權重越大,表示轉寄的訪問請求更多。取值範圍:0~100。
|
100 |
| ServerGroupStickySession |
object |
否 |
伺服器群組之間工作階段保持。 |
|
| Enabled |
boolean |
否 |
是否開啟會話保持。取值:
|
false |
| Timeout |
integer |
否 |
逾時時間。單位:秒。取值範圍:1~86400。預設值:1000。 |
100 |
| InsertHeaderConfig |
object |
否 |
寫入標頭欄位配置。 |
|
| Key |
string |
否 |
插入的標頭欄位名稱,長度為 1~40 個字元,支援大小寫字母 a~z、數字、底線(_)和連字號(-)。InsertHeaderConfig 中的標頭欄位名稱不能重複。 說明
不允許將標頭名稱設定為以下欄位(不區分大小寫): |
key |
| Value |
string |
否 |
插入的標頭欄位內容。
|
UserDefined |
| ValueType |
string |
否 |
標頭欄位內容類型。取值:
|
UserDefined |
| Order |
integer |
是 |
轉發規則動作執行的順序,取值範圍:1~50000,按值從小到大執行動作。值不能為空,不能重複。 |
1 |
| RedirectConfig |
object |
否 |
重新導向配置。 說明
RedirectConfig 的參數,除了 httpCode 外,不能都使用預設值。 |
|
| Host |
string |
否 |
要跳轉的主機位址。取值:
|
${host} |
| HttpCode |
string |
否 |
跳轉方式。取值:301、302、303、307 或 308。 |
301 |
| Path |
string |
否 |
要跳轉的路徑。取值:
|
/test |
| Port |
string |
否 |
要跳轉的連接埠。
|
10 |
| Protocol |
string |
否 |
要跳轉的通訊協定。取值:
說明
|
HTTP |
| Query |
string |
否 |
要跳轉的查詢字串。
|
${query} |
| RewriteConfig |
object |
否 |
重寫配置。 說明
同一個轉發規則配置多個動作時,RewriteConfig 動作使用時必須配置 ForwardGroup 的動作類型。 |
|
| Host |
string |
否 |
內部跳轉的目的主機位址。取值:
|
www.example.com |
| Path |
string |
否 |
要跳轉的路徑。取值:
|
/tsdf |
| Query |
string |
否 |
內部跳轉的查詢字串。
|
${query} |
| Type |
string |
是 |
動作類型。取值:
說明
一個轉發規則必須包含有一條 ForwardGroup(轉發至)、Redirect(重新導向)或 FixedResponse(返回固定回應)轉發動作,與其他類型轉發動作並存時,必須放在最後執行。 |
ForwardGroup |
| TrafficLimitConfig |
object |
否 |
流量限速。 |
|
| QPS |
integer |
否 |
每秒請求次數。取值範圍:1~1000000。 |
100 |
| PerIpQps |
integer |
否 |
單一 IP 每秒請求次數。取值範圍:1 ~ 1000000。 說明
如果同時配置 QPS 參數,PerIpQps 參數的取值必須小於 QPS 參數的取值。 |
80 |
| TrafficMirrorConfig |
object |
否 |
流量鏡像。 |
|
| TargetType |
string |
否 |
鏡像的目標類型。取值:
|
ForwardGroupMirror |
| MirrorGroupConfig |
object |
否 |
流量鏡像至伺服器群組。 |
|
| ServerGroupTuples |
array<object> |
否 |
流量鏡像至伺服器組。 |
|
|
object |
否 |
流量鏡像至伺服器組。 |
||
| ServerGroupId |
string |
否 |
伺服器組 ID。 |
sgp-00mkgijak0w4qgz9**** |
| RemoveHeaderConfig |
object |
否 |
移除 HTTP 標頭配置。 |
|
| Key |
string |
否 |
移除的標頭欄位名稱,長度為 1~40 個字元,支援大小寫字母 a~z、數字、底線(_)和連字號(-)。標頭欄位名稱不能重複用於 RemoveHeader 中。
|
test |
| CorsConfig |
object |
否 |
跨來源資源共用。 |
|
| AllowOrigin |
array |
否 |
允許的存取來源清單。支援只配置一個元素
|
|
|
string |
否 |
允許存取的來源。 |
http://example.com |
|
| AllowMethods |
array |
否 |
選擇跨來源存取時允許的 HTTP 方法。 |
|
|
string |
否 |
選擇跨來源存取時允許的 HTTP 方法。取值:
|
GET |
|
| AllowHeaders |
array |
否 |
允許跨來源的 Header 清單。 |
|
|
string |
否 |
允許跨來源的 Header。支援配置為 |
test_123 |
|
| ExposeHeaders |
array |
否 |
允許公開的 Header 清單。 |
|
|
string |
否 |
允許公開的 Header。支援配置為 |
test_123 |
|
| AllowCredentials |
string |
否 |
是否允許攜帶憑證資訊。取值:
|
on |
| MaxAge |
integer |
否 |
預檢請求在瀏覽器的最大快取時間,單位:秒。 取值範圍:-1~172800。 |
1000 |
| RuleConditions |
array<object> |
是 |
轉發規則條件清單。 |
|
|
array<object> |
是 |
轉發規則條件。 |
||
| CookieConfig |
object |
否 |
Cookie 配置。 |
|
| Values |
array<object> |
否 |
Cookie 值清單。 |
|
|
object |
否 |
Cookie 值結構體。 |
||
| Key |
string |
否 |
Cookie 鍵。
|
test |
| Value |
string |
否 |
Cookie 值。
|
test |
| HeaderConfig |
object |
否 |
標頭欄位配置。 |
|
| Key |
string |
否 |
標頭欄位索引鍵。
|
Port |
| Values |
array |
否 |
標頭欄位值清單。 |
|
|
string |
否 |
HTTP 標頭值清單。同一個轉發規則條件內標頭欄位值不能重複。
|
5006 |
|
| HostConfig |
object |
否 |
主機配置。 |
|
| Values |
array |
否 |
主機名稱清單。 |
|
|
string |
否 |
主機名稱。一個轉發規則條件中只能有一個主機名稱,並且取值不能重複。
|
www.example.edu |
|
| MethodConfig |
object |
否 |
請求方法配置。 |
|
| Values |
array |
否 |
請求方法清單。 |
|
|
string |
否 |
請求方法。 取值:HEAD、GET、POST、OPTIONS、PUT、PATCH、DELETE。 |
PUT |
|
| PathConfig |
object |
否 |
轉發路徑配置。 |
|
| Values |
array |
否 |
轉發路徑清單。 |
|
|
string |
否 |
轉發路徑。取值範圍:
|
/test |
|
| QueryStringConfig |
object |
否 |
查詢字串配置。 |
|
| Values |
array<object> |
否 |
查詢字串清單。 |
|
|
object |
否 |
查詢字串。 |
||
| Key |
string |
否 |
查詢字串鍵。
|
test |
| Value |
string |
否 |
查詢字串值。
|
test |
| ResponseStatusCodeConfig |
object |
否 |
回應狀態碼配置。 |
|
| Values |
array |
否 |
回應狀態碼清單。 |
|
|
string |
否 |
回應狀態碼。 |
test |
|
| ResponseHeaderConfig |
object |
否 |
標頭條件配置。 |
|
| Key |
string |
否 |
標頭欄位索引鍵。
|
test |
| Values |
array |
否 |
標頭欄位值清單。 |
|
|
string |
否 |
標頭欄位值。
|
50006 |
|
| Type |
string |
是 |
轉發規則類型。取值:
|
Host |
| SourceIpConfig |
object |
否 |
基於來源 IP 業務流量比對配置。當 Type 為 SourceIP 時必選且有效。 |
|
| Values |
array |
否 |
基於來源 IP 業務流量比對清單。 |
|
|
string |
否 |
新增一個或多個 IP 位址或者 IP 位址區段。 |
192.168.0.0/32 |
|
| RuleName |
string |
是 |
轉發規則名稱。
|
rule-doc |
| Tag |
array<object> |
否 |
標籤清單。 |
|
|
object |
否 |
標籤結構。 |
||
| Key |
string |
否 |
標籤索引鍵。最多支援 128 個字元,不能以 aliyun 或 acs: 開頭,不能包含 http:// 或 https://。 |
env |
| Value |
string |
否 |
最多支援 128 個字元,不能以 aliyun 或 acs: 開頭,不能包含 http:// 或 https://。 |
product |
返回參數
|
名稱 |
類型 |
描述 |
樣本值 |
|
object |
返回資料結構體。 |
||
| JobId |
string |
非同步任務 ID。 |
72dcd26b-f12d-4c27-b3af-18f6aed5**** |
| RequestId |
string |
請求 ID。 |
365F4154-92F6-4AE4-92F8-7FF34B540750 |
| RuleId |
string |
轉發規則 ID。 |
rule-a3x3pg1yohq3lq**** |
樣本
正常返回樣本
JSON格式
{
"JobId": "72dcd26b-f12d-4c27-b3af-18f6aed5****",
"RequestId": "365F4154-92F6-4AE4-92F8-7FF34B540750",
"RuleId": "rule-a3x3pg1yohq3lq****"
}
錯誤碼
|
HTTP status code |
錯誤碼 |
錯誤資訊 |
描述 |
|---|---|---|---|
| 400 | IncorrectStatus.Listener | The status of %s [%s] is incorrect. | |
| 400 | OperationDenied.SameGroupForForwardAndMirrorAction | The operation is not allowed because of %s. | |
| 400 | OperationDenied.IpGroupCanNotUsedForMirrorAction | The operation is not allowed because of %s. | |
| 400 | OperationDenied.GRPCServerGroup | The operation is not allowed because of %s. | |
| 400 | Conflict.Priority | There is already %s having the same configuration with %s. | |
| 400 | ResourceQuotaExceeded.LoadBalancerRulesNum | The quota of %s is exceeded for resource %s, usage %s/%s. | |
| 400 | ResourceQuotaExceeded.ServerGroupAttachedNum | The quota of %s is exceeded for resource %s, usage %s/%s. | |
| 400 | ResourceQuotaExceeded.LoadBalancerServersNum | The quota of %s is exceeded for resource %s, usage %s/%s. | |
| 400 | ResourceQuotaExceeded.ServerAddedNum | The quota of %s is exceeded for resource %s, usage %s/%s. | |
| 400 | QuotaExceeded.RuleWildcardsNum | The quota of %s is exceeded, usage %s/%s. | |
| 400 | QuotaExceeded.RuleMatchEvaluationsNum | The quota of %s is exceeded, usage %s/%s. | |
| 400 | QuotaExceeded.RuleActionsNum | The quota of %s is exceeded, usage %s/%s. | |
| 400 | Mismatch.Protocol | The %s is mismatched for %s and %s. | |
| 400 | Mismatch.VpcId | The %s is mismatched for %s and %s. | |
| 400 | OperationDenied.RewriteMissingForwardGroup | The operation is not allowed because of RewriteMissingForwardGroup. | |
| 400 | ResourceInConfiguring.Listener | The specified listener is being configured, please try again later. | |
| 400 | OperationDenied.MirrorActionSupportHttpGroupOnly | The operation is not allowed because of MirrorActionSupportHttpGroupOnly. | |
| 400 | OperationDenied.ProtocolMustSameForForwardGroupAction | The operation is not allowed because of ProtocolMustSameForForwardGroupAction. | |
| 404 | ResourceNotFound.Listener | The specified resource %s is not found. | |
| 404 | ResourceNotFound.ServerGroup | The specified resource %s is not found. |
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。