Skip to main content

Route Matching Rules

CloudBase HTTP access service provides flexible route configuration capabilities, allowing you to precisely route requests to various backend resources such as cloud run, cloud functions, and static hosting, achieving unified request distribution management.

Route configuration consists of two core elements: domain and path. The system matches based on these two elements according to specific priorities.

Matching Priority

  1. Domain Matching:

    • Exact match (e.g. example.com) has higher priority than wildcard match (e.g. *)
    • Supports using wildcard * to match any domain
  2. Path Matching:

    • Follows longest match principle, the system will prioritize rules with the highest overlap with the request path
    • Path matching is prefix matching, e.g. /bar can match /bar/xxx

Matching Flow Diagram

Route Matching Flow

Route Matching Examples

The following table shows a set of route rule configurations:

DomainPathAssociated Resource
*/FunctionA
*/barFunctionB
<Default Domain>/barFunctionC
foo.com/FunctionD
foo.com/barFunctionE
foo.com/bar/bazFunctionF

Request Matching Results

Based on the above configuration, different requests will be routed to different resources:

Access AddressMatched ResourceMatching Reason
<Default Domain>/xxxFunctionADomain matched via wildcard *, path /xxx matches prefix /
<Default Domain>/barFunctionCExact match default domain, path exact match /bar
<Default Domain>/bar/xxxFunctionCExact match default domain, path /bar/xxx matches prefix /bar
foo.com/xxxFunctionDExact match domain foo.com, path /xxx matches prefix /
foo.com/barFunctionEExact match domain foo.com, path exact match /bar
foo.com/bar/xxxFunctionEExact match domain foo.com, path /bar/xxx matches prefix /bar
foo.com/bar/bazFunctionFExact match domain foo.com, path exact match /bar/baz (longest match principle)