When a cloud-native gateway receives access requests, the gateway matches the requests with routes one by one based on the priorities of routing rules. The gateway matches the requests with routes based on the priorities of routing rules in descending order. If a request matches a route, the request is routed to the destination service. If the request fails to match a route, the error code 404 is returned.
Route matching priorities
If multiple routing rules exist, the priorities of the routing rules are sorted in the following order from the highest to the lowest: associated domain name > path > request header > request parameters > creation time.
Determine the priority of a route based on its domain name. The longer the length of the domain name string of a route, the higher the priority of the route.
Determine the priority of a route based on the path of the route in the following scenarios:
If the path matching rules of multiple routes are different, the priorities of the routes are sorted based on the following conditions from the highest to the lowest: Equal To > Prefix > Regular Expression Match.
If the path matching rules of multiple routes are the same, the longer the path string of a route, the higher the priority of the route.
Determine the priority of a route based on the total number of key-value pairs in the request header for the route. The larger the total number of key-value pairs in the request header for a route, the higher the priority of the route.
Determine the priority of a route based on the total number of key-value pairs in the request parameters for the route. The larger the total number of key-value pairs in the request parameters for a route, the higher the priority of the route.
Determine the priority of a route based on its creation time. The earlier the creation time of a route, the higher the priority of the route.
Procedure
Log on to the MSE console. In the top navigation bar, select a region.
In the left-side navigation pane, choose Cloud-native Gateway > Gateways. On the Gateways page, click the name of the gateway.
In the left-side navigation pane, click the Routes tab. On the Routes tab, click Add Route.
On the Add Route page, configure the parameters and click Save.
NoteA route is matched when all conditions in the routing rule are met. If you specify more conditions, fewer requests can be matched.
A request matches routes based on the order that is displayed on the Routes page.
Parameter
Description
Route Name
The name of the route that you want to create. You can click Add Description and enter a description for the route in the Route Description field.
Domain name
Select one or more domain names that you want to match for the route.
If you want to create a domain name, click Add Domain Name below the Domain name drop-down list, and configure the parameters to create a domain name in the Add Domain Name panel.
Match Rule
Path
The Path parameter in the HTTP requests that you want to forward in the route.
If the path matching rules of multiple routes are the same, the longer the Path value of a route, the higher the priority of the route.
If the path matching rules of multiple routes are different, the priorities of the routes are sorted based on the following conditions from the highest to the lowest: Equal To > Prefix > Regular Expression Match.
Equal To: A complete path is used to match requests with a route. For example, you can set the Path parameter to
/user
.Prefix: A path prefix is used to match requests with a route. For example, you can specify the prefix as
/user
.Regular Expression Match: A regular expression is used to match requests with a route.
Method
The Method parameter that is used to match HTTP requests with a route. You can specify multiple values for the Method parameter to match more requests with a route. By default, ANY is selected.
Header
The Header parameter that is used to match HTTP requests with a route. If multiple routes have the same matching conditions aside from the number of specified Header parameters, a route that has a larger number of the Header parameters in the rule has a higher priority.
Query Parameters
The Query parameter that is used to match HTTP requests with a route. If multiple routes have the same matching conditions aside from the number of specified Query parameters, a route that has a larger number of the Query parameters in the rule has a higher priority.
Scenario
Select the type of the destination service for the route.
Basic Scenario: Single Service
Canary Release Scenario: Multiple Services and Tag-based Routing
Other Scenarios: Mock and Redirect
For more information about the types of destination services, see Routing modes.
NoteThe sum of the traffic percentages of the destination services for which you configure the weight must be 100%.
Backend Service
Select the associated backend service and port.
NoteYou can select Associate Service from the Service Name drop-down list and select a source and a service in the Associate Service panel.
The number of sources that can be added varies based on the source type.
If Source Type is set to Container Service, a maximum of five sources can be added.
If Source Type is set to MSE Nacos or MSE Zookeeper, only one source can be added.
If Source Type is set to EDAS Built-in Registry or SAE Built-in Registry, an unlimited number of sources can be added.
Fallback
Specify a fallback service based on your business requirements. If no node is available for the backend service to which the route points, the original request accesses the fallback service that you specified.
NoteOnly the fallback capability between HTTP services is supported.
Timeout Period (s)
Enter a timeout period. The default value is 60. If you set the value to 0, no timeout occurs.
Number of Retries (times)
Enter the number of retries. The default value is 2. If you set this value to 0, retry is not allowed.
Retry Condition
Select a retry condition.
Retry Status Code
Add one or more retry status codes.
References
You can modify routing rules at any time based on your business requirements. For more information, see Modify a routing rule.