All Products
Search
Document Center

Serverless App Engine:Set up routing rules for an application (API Gateway)

Last Updated:Aug 06, 2025

To distribute business requests to other services or applications, you can configure the gateway routing feature. This topic describes how to set up routing rules for your application using a cloud-native API Gateway.

Background information

A cloud-native API Gateway is a unified architecture solution that integrates the features of traffic gateways, microservice gateways, security gateways, and AI gateways. It is designed to address the challenges caused by the decentralized management of traditional gateways. Using a cloud-native API gateway, developers can more easily manage service discovery, load balancing, and cross-service communication, which simplifies the development and maintenance of complex distributed systems. For more information, see What is a cloud-native API gateway?

Prerequisites

  • MSE

  • SAE

    • You have created a namespace and ensured that the cloud-native API Gateway and the SAE namespace are in the same region and are bound to the same VPC. For more information, see Create a namespace.

    • You have created an application.

Create a routing rule

  1. On the SAE Gateway Routing page, select a region and namespace, and then click Create Gateway Route.

  2. On the Create Route page, configure the parameters and click Save.

    Configuration Item

    Description

    Example

    Route Name

    The name of the routing rule. You can customize the name.

    demo

    Network Type

    Select the network type for the requests to be forwarded.

    • Internet: For requests forwarded through an Internet gateway, you are charged based on the actual forwarded traffic.

    • Private: Requests forwarded through a private gateway are not charged. They are forwarded only within the current VPC.

    Internet

    Gateway Type

    Select Cloud-native API Gateway.

    Cloud-native API Gateway

    Gateway Instance

    This parameter is required when Gateway Type is set to Cloud-native API Gateway. Select a gateway instance that is in the same region and uses the same VPC as the namespace. To create a new gateway instance, you can click Create Cloud-native API Gateway. For more information, see Create a cloud-native API Gateway instance.

    demo

    Domain Name

    Select one or more domain names that you want to match. To create a new domain name, you can click Create Domain Name. For more information, see Create a domain name.

    www.demo.com

    Path

    Set the Path parameter to match in HTTP requests.

    • If multiple rules have the same matching condition, the rule with the longer path has a higher priority.

    • If rules have different matching conditions, the priority is as follows, from highest to lowest: Equals > Prefix > Regular Expression.

      • Equals: an exact match. For example, the path is equal to /user.

      • Prefix: a prefix match. For example, the path starts with /user.

      • Regular Expression: a regular expression match. For example, the character class is user.

    • Condition: Prefix

    • Path: /user

    Method

    Set the Method parameter to match in HTTP requests. If you leave this parameter empty, all methods are matched. You can select multiple HTTP methods.

    GET

    Request Header

    Set the Header parameter to match in HTTP requests. If multiple rules have the same matching condition, the rule with more parameters has a higher priority.

    • Request header: demo

    • Condition: Prefix

    • Value: value

    Request Parameter (Query)

    Set the Query parameter to match in HTTP requests. If multiple rules have the same matching condition, the rule with more parameters has a higher priority.

    • Request header: key

    • Condition: Prefix

    • Value: value

    Service Source

    MSE Nacos and K8s Service are supported as service registries.

    • MSE Nacos: If you select this option, you must set the MSE Nacos Instance and MSE Nacos Namespace parameters.

    • K8s Service: SAE supports multi-language service registration and discovery using Kubernetes ServiceNames. It also lets you configure applications with fixed domain names to resolve the issue of instance IP address changes after deployment.

    Note

    The service source must be consistent with the service registration and discovery method of the application.

    MSE Nacos Instance

    Scenarios

    Select the type of the destination service for the current route.

    • Basic scenario

      Single Service: distributes requests to a single backend service. This is the most common scenario.

    • Grayscale scenario

      Multiple Services: distributes requests to multiple backend services based on specified proportions. This is typically used in traffic shifting and grayscale release scenarios.

    For more information about different types of destination services, see Overview of routing methods.

    Single Service

    Backend Service

    Select the backend application, service, and its corresponding port.

    Note

    The sum of traffic weight percentages for all destination services must be 100%.

    • Application name: demo

    • Service name: demo

    • Service protocol: Auto Read

    • Service port: 80

    Advanced Configuration

    Fallback

    Turn on the Fallback switch and set the fallback service. You need to select a specific service. When no available node exists for the backend service to which the route points, the original request is sent to the specified fallback service.

    Note

    Currently, fallback is supported only between HTTP services.

    Enabled

    Timeout (s)

    Enter the timeout period. The default value is 60 seconds. A value of 0 indicates no timeout.

    60

    Retries

    Enter the number of retries. A value of 0 disables retries.

    2

    Retry Conditions

    Select the retry conditions. For more information, see Configure a retry policy.

    connect-failure, cancelled

    Retry Status Codes

    Add the retry status codes. This is the message displayed after an error occurs.

    502

    After the routing rule is created, you can view, edit, and perform other operations on the Gateway Routing page.

Manage routing rules

After you create a routing rule, you can view forwarding rules, and edit or delete gateway routes on the Gateway Routing page.