This topic describes how to bind a custom domain name to a web application in the Function Compute console.


  • An HTTP function is created. For more information, see Procedure.

    Requests sent from a custom domain name can trigger only HTTP functions.

  • An Internet Content Provider (ICP) license for the custom domain name is applied for by using the Alibaba Cloud ICP Filing system or Alibaba Cloud is added as a service provider to the ICP filing information of the custom domain name. For more information, see ICP filing application overview.
  • A canonical domain name (CNAME) is configured for your custom domain name. If you use Alibaba Cloud DNS, see the specific procedure inQuick Start.


  1. Log on to the Function Compute console.
  2. In the top navigation bar, select a region.
  3. In the left-side navigation pane, click Custom Domain.
  4. Click Create Domain.
  5. In the Add Custom Domain panel, set the parameters and click OK.
    Parameter Configuration method
    Custom Domain Name Enter a custom domain name that has obtained an ICP filing by using the Alibaba Cloud ICP Filing system or whose ICP filing information includes Alibaba Cloud as a service provider.
    CDN Acceleration Turn on or turn off CDN Acceleration based on your requirements.
    • Turn on: enables CDN acceleration.

      If you turn on CDN Acceleration, you must enter a domain name for CDN in the Accelerated Domain field. Then, log on to the CDN console and configure a CNAME for the domain name for CDN. For more information, see Enable CDN acceleration for Function Compute origins.

    • Turn off: disables CDN acceleration.
    Protocol Select a protocol that the custom domain name supports from the Protocol drop-down list. Valid values:
    • HTTP: The custom domain name can be accessed only over HTTP.
    • HTTP,HTTPS: The custom domain name can be accessed over HTTP and HTTPS.
      To allow users to access your custom domain name over HTTPS, you must select Certificate Type:
      • If you select Alibaba Cloud Security Certificate, you must select an Alibaba Cloud security certificate from the Certificate Name drop-down list.
      • If you select Custom Certificate, you must enter a certificate name in the Certificate Name field, the certificate in the Privacy-Enhanced Mail (PEM) encoding format in the Certificate field, and the private key in the PEM encoding format in the Private Key field. You can also click manage and upload certificates to go to the SSL Certificates Service console and upload your certificate. Make sure that the certificate you want to upload does not exceed 20 KB, and the private key does not exceed 4 KB. If you do not have an available certificate, you can click issue certificates to issue a certificate.
    Routing Config
    Notice You can configure custom domain names only for functions that have HTTP triggers. Create an HTTP trigger function before you configure routes.
    Configure the relationship between paths and functions. This way, requests from different paths can trigger different functions. You must set the following fields:
    • Path: the path from which a request can trigger the specified function.
    • Service Name: the name of the service to which the specified function belongs.
    • Function Name: the name of the function triggered by a request from the specified path.
    • Version/Alias: the version or alias of the specified function.

    For more information about routes, see Routing rules.

    Note You can configure multiple routes.

Routing rules

You must configure the relationship between paths and functions when you bind a custom domain name. This way, requests from different paths can trigger different functions. Function Compute supports exact match and fuzzy match for paths. These matching rules are implemented in the following manner:
  • Exact match: A function is triggered only when the path of the request is exactly the same as the specified path.

    For example, you have created a route whose path is /a, corresponding service is s1, corresponding function is f1, and corresponding version is 1. Only requests from exactly the /a path can trigger the f1 function of version 1. Requests from the /a/ path cannot trigger the f1 function of version 1.

  • Fuzzy match: You can append an asterisk (*) as a wildcard character to a path.

    For example, you have created a route whose path is /login/*, corresponding service is s2, corresponding function is f2, and corresponding version is 1. Requests from all paths that begin with /login/, such as /login/a and /login/b/c/d, can trigger the f2 function of version 1.

  • If multiple routes are configured for one custom domain name, an exact match takes precedence over a fuzzy match.
  • For a request URL that has multiple fuzzy matches, the longest prefix match (LPM) rule determines the path to use.

    For example, the /login/a/* path and the /login/* path are configured for the custom domain name, and the request URL is The request URL matches both configured paths. However, based on the LPM rule, the /login/a/* path is used.


For example, the custom domain name is The following table shows five routing rules configured based on the steps described in this topic.
Routing rule Path Service name Function name Version
Routing rule 1 / s1 f1 1
Routing rule 2 /* s2 f2 2
Routing rule 3 /login s3 f3 3
Routing rule 4 /login/a s4 f4 4
Routing rule 5 /login/* s5 f5 5
The following table shows the final matches.
Request URL Matched service name Matched function name Matched version Matched path s1 f1 1 / s2 f2 2 /* s3 f3 3 /login s4 f4 4 /login/a s5 f5 5 /login/* s5 f5 5 /login/*

Verify the results

After the configuration is complete, you can use one of the following methods to access the custom domain name and verify the results:

  • Method 1: Run the curl URL command. For example, run curl
  • Method 2: Use a browser.

    Enter the request URL in a web browser and then press the Enter key to check whether the specified function is called.