Creates a routing rule.
Debugging
Request headers
This operation uses only common request headers and does not have operation-specific request headers. For more information, see Common request and response headers.
Request syntax
POST /pop/v1/sam/ingress/Ingress HTTP/1.1
Request parameters
Parameter | Type | Position | Required | Example | Description |
NamespaceId | String | Query | Yes | cn-beijing:sae-test | The ID of the namespace to which the application belongs. You can specify only one namespace ID each time you call this operation. |
Description | String | Query | No | ingress-for-sae-test | The name of the routing rule. |
SlbId | String | Query | Yes | lb-uf6hucc7inlqrtcq5**** | The Server Load Balancer (SLB) instance that is used by the routing rule. |
ListenerPort | Integer | Query | Yes | 80 | The listener port of the SLB instance. You must specify a vacant port. |
CertId | String | Query | No | 188077086902****_176993d****_181437****_108724**** | The ID of the certificate that is associated with the Classic Load Balancer (CLB) instance.
For information about how to manage the SSL certificate IDs that are used by CLB instances, see Manage certificates (CLB). |
CertIds | String | Query | No | 87***35-cn-hangzhou,812***3-cn-hangzhou | The IDs of the certificates that are associated with the Application Load Balancer (ALB) instance.
|
DefaultRule | String | Query | Yes | {"appId":"395b60e4-0550-458d-9c54-a265d036****","containerPort":8080} | The default forwarding rule. You can specify a port and an application in the default forwarding rule to forward traffic based on the IP address of the application. The following parameters are involved:
Note All requests that do not match the forwarding rules specified in the Rules parameter are forwarded over the port to the specified application. |
Rules | String | FormData | Yes | [{"appId":"395b60e4-0550-458d-9c54-a265d036****","containerPort":8080,"domain":"www.sae.site","path":"/path1"},{"appId":"666403ce-d25b-47cf-87fe-497565d2****","containerPort":8080,"domain":"sae.site","path":"/sys/(.*)/(.*)/aaa","rewritePath":"/${1}","backendProtocol":"http"}] | The forwarding rules. You can specify a port and an application in a forwarding rule to forward traffic based on the specified domain name and request path. The following parameters are involved:
|
LoadBalanceType | String | Query | No | clb | The type of the SLB instance based on the processing capabilities. The instance type can be specified only when you create a routing rule. You cannot change the instance type when you update the routing rule. Valid values:
|
ListenerProtocol | String | Query | No | HTTP | The protocol that is used to forward requests. Valid values:
|
Response parameters
Parameter | Type | Example | Description |
RequestId | String | 91F93257-7A4A-4BD3-9A7E-2F6EAE6D**** | The request ID. |
Message | String | success | The returned message. Valid values:
|
TraceId | String | 0a98a02315955564772843261e**** | The trace ID that is used to query the details of the request. |
Data | Object | The returned result. |
|
IngressId | Long | 87 | The ID of the routing rule. |
ErrorCode | String | Null | The error code. Valid values:
|
Code | String | 200 | The HTTP status code. Valid values:
|
Success | Boolean | true | Indicates whether the routing rule was created. Valid values:
|
Examples
Sample requests
POST /pop/v1/sam/ingress/Ingress?NamespaceId=cn-beijing:sae-test&Description=ingress-for-sae-test&SlbId=lb-uf6hucc7inlqrtcq5****&ListenerPort=80&CertId=188077086902****_176993d****_181437****_108724****&DefaultRule={"appId":"395b60e4-0550-458d-9c54-a265d036****","containerPort":8080}&LoadBalanceType=clb&ListenerProtocol=HTTP HTTP/1.1
Host:sae.aliyuncs.com
Content-Type:application/json
Rules=[{"appId":"395b60e4-0550-458d-9c54-a265d036****","containerPort":8080,"domain":"www.sae.site","path":"/path1"},{"appId":"666403ce-d25b-47cf-87fe-497565d2****","containerPort":8080,"domain":"sae.site","path":"/path2"}]
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateIngressResponse>
<RequestId>91F93257-7A4A-4BD3-9A7E-2F6EAE6D****</RequestId>
<Message>success</Message>
<TraceId>0a98a02315955564772843261e****</TraceId>
<Data>
<IngressId>87</IngressId>
</Data>
<Code>200</Code>
<Success>true</Success>
</CreateIngressResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "91F93257-7A4A-4BD3-9A7E-2F6EAE6D****",
"Message" : "success",
"TraceId" : "0a98a02315955564772843261e****",
"Data" : {
"IngressId" : 87
},
"Code" : "200",
"Success" : true
}
Error codes
HttpCode | Error code | Error message | Description |
400 | InvalidParameter.NotEmpty | You must specify the parameter %s. | The value of the %s parameter is invalid. This parameter cannot be left empty. |
400 | InvalidParameter.Obviously | The specified parameter is invalid {%s}. | The value of the {%s} parameter is invalid. |
400 | InvalidParameter.WithMessage | The parameter is invalid {%s}: %s | The value %s of the {%s} parameter is invalid. |
400 | Slb.NotFound | The SLB instance does not exist: slbId [%s] | The SLB instance slbId[%s] does not exist. |
400 | Exceed.IngressRule | The number of Ingress related rules must be less than or equal to 40. | The number of routing rules cannot exceed 40. |
400 | SlbListenerPort.NotAvailable | The SLB listening port is unavailable: slbId [%s], port [%s] | The listener port [%s] of the SLB instance whose ID is [%s] is occupied. |
400 | SSLCert.NotFound | The specified SSL certificate cannot be found. | The SSL certificate is not found. |
404 | InvalidResponse.Api | The response of API %s is empty. | The response of this operation is empty. |
For a list of error codes, see Service error codes.