You can configure a domain name as a trigger to access Functions and Pages through a custom public path. Edge Security Acceleration (ESA) provides two methods to direct HTTP or HTTPS requests to your Functions and Pages service: Custom Domains and Routes.
Before you begin
Both Custom Domains and Routes require an active site in your account.
An active site is a site that has a purchased plan and is connected using an NS or CNAME record.
Choose the right configuration method

Attribute | Custom Domains | Routes |
Core purpose | Forwards all requests from a specified domain name, such as | Routes only the requests that match a preset path, such as |
Scope | All traffic under the domain name | Partial traffic that matches the rule |
Configuration method | Simple, one-step configuration | Flexible. Requires configuring matching rules. |
Scenarios |
|
|
Use domain binding
Use Custom Domains to direct all traffic from a domain name to a specific Functions and Pages service for processing.
The domain binding feature lets you link a Functions and Pages service to your site's domain name. After the domain name is bound, you can use it to directly access the Functions and Pages service. The domain name bound to the Functions and Pages service must belong to an active site. After you configure the binding in the console, ESA automatically adds a DNS record for the bound domain name to the site.
Log on to the ESA console. In the navigation pane on the left, choose . Click the Functions and Pages service that you want to configure.
Click the Domain Names tab. In the Custom Domains section, click Add Domain Name.

Enter the domain name that you want to bind to the Functions and Pages service, such as
pages.example.com. After the domain name is added, a new DNS record is created for the corresponding site.NoteThe new domain name inherits the configurations of its site. If the site does not have an SSL/TLS certificate, the bound domain name cannot be accessed over HTTPS. For more information about how to enable SSL/TLS for a site, see SSL/TLS.

Follow the steps that correspond to your site's connection type:
Site connected using NS setup
If your site is connected using an NS record, wait for the DNS record to take effect. This process takes about one minute. Then, access the newly bound custom domain name, such as
pages.example.com, in a browser to view the result.
Site connected using CNAME setup
If your site is connected using a CNAME record, you must configure a CNAME record with your DNS provider for the binding to take effect.
Click View DNS Records to the right of the newly added custom domain name.

Copy the CNAME value that ESA generated for the new DNS record.

Go to your DNS provider and add a CNAME record to your domain name's DNS settings:
Host Record: Enter the prefix of the custom domain name. In this example, enter
pages.Record Type: Select
CNAME.Record Value: Paste the CNAME value that you copied in the previous step.

Return to the ESA console. Wait until the CNAME Status changes to Configured.
Then, access the newly bound custom domain name, such as pages.example.com, in a browser to view the result.
Use routing configuration
You can use routing to forward requests for specific URL paths to a Functions and Pages service. This method provides fine-grained traffic shaping. If a request matches a configured URL pattern, the Functions and Pages service processes it. Otherwise, the request continues through the ESA accelerated back-to-origin process. For example, if you configure the routing rule example.com/a* for the example.com site, all requests to matching paths, such as /a, /a1, and /a2, are processed by the Functions and Pages service. Requests to non-matching paths, such as /b, /c, and /d, follow the standard back-to-origin or caching process.
Log on to the ESA console. In the navigation pane on the left, choose . Click the Functions and Pages service that you want to configure.
Click the Domain Names tab. In the Routes section, click Add Route.

Enter a Routing Name. In the Select Site list, select the target site, for example,
example.com.Select a Routing Pattern:
Basic mode: This pattern matches requests based only on the URL, which includes the hostname and path. For example, you can configure all requests with the URL prefix
pages.example.comto be routed to a Functions and Pages service:
Custom Pattern: This pattern is suitable for scenarios that require complex logical matching based on multiple conditions, such as request headers, cookies, and request methods. You can add multiple matching conditions and specify the logical relationship between them as either "meet all" or "meet any". For example, you can configure a rule that forwards a request to a Functions and Pages service only if the
hostnameequalswww.example.comand theUser-Agentrequest header containsMobile:
Access a matching routing path in a browser to view the result.

If you use basic mode and enter a domain name with a prefix, such as
*.example.comorwww.example.com, a corresponding record must exist in the DNS Records section of the ESA console. You can also manually add a record. Otherwise, access to the domain name fails.If multiple routing rules are configured, they are matched sequentially from top to bottom. After a match is found, subsequent rules are not checked.
Matching rules
A routing configuration must include both the domain hostname and the path URI. Therefore, you cannot configure a routing rule that contains only a path URI, such as
/path.You can add a wildcard character (
*) at the beginning or end of a routing configuration to match more requests. The wildcard character*matches zero or more of any character. For example,example.com/*matches all requests toexample.com.Routing configurations are case-sensitive. For example,
example.com/aandexample.com/Aare two different routing rules.Routing configurations do not support wildcard characters (
*) in the middle of a path or in parameters. For example,example.com/*/pathandexample.com/path?param=1are not allowed.If a request matches multiple routing rules, the first matching rule in the list takes precedence.
Bypass mode
After you enable bypass mode for a routing rule, when a request matches the routing policy, the request is sent to the Functions and Pages service as a sub-request. The overall process of bypass mode is as follows:
A client sends a request to an ESA point of presence (POP).
The request matches a routing policy and is forwarded to the Functions and Pages service for processing. In the Functions and Pages service, you can perform operations such as logging and authentication based on the request content. Note that when bypass mode is enabled, the request body is not forwarded to the Functions and Pages service.
If the response from the Functions and Pages service has a status code of
200, the request proceeds to the next processing step. If the status code is not 200, ESA aborts the request and returns a403status code to the client.The request is then matched against subsequent policies and proceeds through the ESA cache matching or accelerated back-to-origin logic.
The response from a cache hit or from the origin server is returned to the ESA POP. At this point, the response is no longer processed by the Functions and Pages service.
The response is forwarded to the client.
Common scenarios
Logging: If you want to generate logs for some requests, you can forward the requests to a Functions and Pages service in bypass mode and define custom logging logic in the function.
Authentication for large file downloads: When an edge function forwards a response to a client, it consumes CPU time. If the response is too large, it can exceed the CPU time slice limit and incur extra costs. You can use bypass mode to perform authentication with a Functions and Pages service to avoid these issues.