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
Multiple routing rules are prioritized in the following descending order: Domain Name > Path > request header > Query Parameters > Created At.
-
Domain Name: The longer the domain name string, the higher the priority.
-
Path:
-
If the Match Rule is different, the priority is as follows: Equal To > Prefix > Regular Expression Match.
-
If the Match Rule is the same, the longer the Path string, the higher the priority.
-
-
Header: The more key-value pairs in the header, the higher the priority.
-
Query Parameters: The more key-value pairs in the query, the higher the priority.
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 ID of the gateway.
-
In the navigation pane on the left, click Routes. 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
A custom name for the route. To add a description, click Add Description.
Domain Name
Select one or more domain names that you want to match for the route.
To create a domain name, click Add Domain Name.
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 routes use different matching rules, the priority is as follows: Equal To > Prefix > Regular Expression Match.
-
Equal To: An exact match. For example, a path that is exactly
/user. -
Prefix: A prefix match. For example, a path that starts with
/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.
Note-
Click Associate Service to select a source and service.
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.