All Products
Search
Document Center

Serverless App Engine:CreateIngress

Last Updated:Aug 11, 2023

Creates a routing rule.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

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.

  • If LoadBalanceType is set to clb, specify this parameter to configure a certificate for the HTTP listener.

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.

  • If LoadBalanceType is set to alb, specify this parameter to configure multiple certificates for the HTTPS listener. Separate multiple certificate IDs with commas (,).
  • The ID of the SSL certificate that is used by an ALB instance can be obtained from Certificate Management Service. In this example, this parameter is set to 756***-cn-hangzhou. 756*** indicates the certificate ID that is obtained from the service page. -cn-hangzhou indicates the fixed suffix. For more information, see Manage certificates (ALB).
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:

  • appId: the application ID.
  • containerPort: the container port of the application.
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:

  • appId: the application ID.
  • containerPort: the container port of the application.
  • domain: the domain name.
  • path: the request path.
  • backendProtocol: the backend service protocol. Valid values: http, https, and grpc. Default value: http.
  • rewritePath: the rewrite path.
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:

  • clb: a CLB (formerly SLB) instance
  • alb: an ALB instance
ListenerProtocol String Query No HTTP

The protocol that is used to forward requests. Valid values:

  • HTTP: HTTP is suitable for applications that need to identify the transmitted data.
  • HTTPS: HTTPS is suitable for applications that require encrypted data transmission.

Response parameters

Parameter Type Example Description
RequestId String 91F93257-7A4A-4BD3-9A7E-2F6EAE6D****

The request ID.

Message String success

The returned message. Valid values:

  • success: If the call is successful, success is returned.
  • An error code: If the call fails, an error code is returned.
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:

  • If the call is successful, the ErrorCode parameter is not returned.
  • If the call fails, the ErrorCode parameter is returned. For more information, see the "Error codes" section in this topic.
Code String 200

The HTTP status code. Valid values:

  • 2xx: The call was successful.
  • 3xx: The call was redirected.
  • 4xx: The call failed.
  • 5xx: A server error occurred.
Success Boolean true

Indicates whether the routing rule was created. Valid values:

  • true: The routing rule was created.
  • false: The routing rule failed to be created.

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.