Skip to main content

routes

Routing Configuration

CloudBase HTTP Access Service offers flexible routing configuration capabilities, allowing you to precisely route requests to various backend resources such as Cloud Run, Cloud Functions, and Static Hosting, enabling unified request distribution management.

Routing Matching Rules

Routing Configuration consists of two core elements: domain and path. These elements are matched in a specific priority order.

Matching Priority

  1. Domain Matching:

    • Exact matches (e.g., example.com) take precedence over wildcard matches (e.g., *)
    • Supports using wildcard * to match any domain.
  2. Path Matching:

    • Following the longest matching principle, the system prioritizes selecting the rule that best matches the request path.
    • Path matching is prefix matching, such as /bar can match /bar/xxx

Matching Flowchart

Routing Matching Flow

Routing Matching Example

The following table displays a set of routing rule configurations.

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

Request Matching Result

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

Access URLMatched ResourceMatching Reason
<Default Domain Name>/xxxFunctionAThe domain name is matched by the wildcard *, and the path /xxx matches the prefix /
<Default Domain Name>/barFunctionCThe default domain name is matched exactly, and the path /bar is matched exactly
<Default Domain Name>/bar/xxxFunctionCThe default domain name is matched exactly, and the path /bar/xxx matches the prefix /bar
foo.com/xxxFunctionDThe domain name foo.com is matched exactly, and the path /xxx matches the prefix /
foo.com/barFunctionEThe domain name foo.com is matched exactly, and the path /bar is matched exactly
foo.com/bar/xxxFunctionEThe domain name foo.com is matched exactly, and the path /bar/xxx matches the prefix /bar
foo.com/bar/bazFunctionFThe domain name foo.com is matched exactly, and the path /bar/baz is matched exactly (longest matching rule)