All Products
Document Center

Bind custom domains

Last Updated: Feb 14, 2020

By binding custom domains, you can allow users to access the functions that are deployed in Function Compute through the custom domains and to run functions with HTTP triggers. This approach helps you construct web services through Function Compute.

You can bind custom domains in Function Compute and map the paths to functions that are in different services. Then you can access the functions using the corresponding custom domains.

Use cases

For example, assuming that you have a website with a domain name of To achieve lower costs and higher scalability, you want to migrate the web services to Function Compute without affecting services to external users. To be more specific, you want to avoid changing the links associated with the external services. In this case, you can bind custom domains for your services.


Process Without custom domain binding With custom domain binding
Deployment phase
  1. Write the application code and deploy the applications to your server.
  2. Obtain the ICP registration for the domain names.
  3. Resolve the domain names to the IP address of your server.
  4. Map the paths to the services through web frameworks
  1. Write functions for applications in Function Compute and set HTTP triggers.
  2. Obtain or transfer ICP registration for the domain names through Alibaba Cloud.
  3. Resolve the domain names to the address of the Function Compute service:
  4. Bind the domain names in Function Compute and map the paths to the functions.
Access phase
  2. Resolve the domain names to the IP address of the server.
  3. Access the services deployed in the user server.
  2. Resolve the domain names to the address of Function Compute.
  3. Access the functions deployed in Function Compute.


Build a web server based on HTTP triggers in advance. For more information about building a web server, see Tutorial: HTTP triggers.

Bind the custom domains

  1. Obtain or transfer the ICP registration for the domain names through Alibaba Cloud. For more information about ICP registration, see ICP registration guide.

  2. Resolve the domain name to your endpoint. To be specific, resolve the CNAME records to the domain name that is pointed to the endpoint IP address. Set CNAME records before binding in Function Compute.

    For example, if your domain name is, your account ID is 12345, and your Function Compute service is deployed in the China (Shanghai) region, then you must set the CNAME of to be

  3. Bind the custom domain names in Function Compute, and map the paths to the functions.

    Note: Functions that are bound to the same domain name must be deployed in the same region but can belong to different services.

    For example, you can trigger the execution of function1 in service1 by the request path “/a” and trigger the execution of function2 in service2 by the request path “/b”.

    Only functions that have HTTP triggers configured can be triggered for execution through custom domain names.

Routing rules

You must map the paths to the functions for the custom domain names. Executions of different functions are triggered by different request paths. Function Compute supports exact matching and fuzzy matching. Specific rules are as follows:

Exact matching

For exact matching, the actual request path must be exactly the same as the request path that is set. For example, if path /a is set to trigger the execution of function f1 of service s1 (referred to as “s1/f1”) the path /a/ cannot trigger the execution of f1.

Fuzzy matching

It supports the wildcard character * included only at the end of the path. For example, /login/* represents all of the request paths. Specifically, the prefixes /login/ and /login/* are mapped to s2/f2. In this case, both /login/a and /login/b/c/d trigger the execution of f2.

  • Matching priority: exact match first and then fuzzy match
  • Matching algorithm: longest prefix match


Assuming that the domain name is, and the routing rules are as follows:

Path ServiceName FunctionName
/ s1 f1
/* s2 f2
/login s3 f3
/login/a s4 f4
/login/* s5 f5

The matching results are as follows:

RequestURI MatchedServiceName MatchedFunctionName MatchedPath s1 f1 / s2 f2 /* s3 f3 /login s4 f4 /login/a s5 f5 /login/* s5 f5 /login/*

Upload HTTPS Certificate

If you would like to use HTTPS protocol to access custom domain, you need upload the certificate and private key. The certificate and private key need to follow PEM format, and size of it should not exceed 4k.

Console operation

  1. Log on to the Go to the Function Compute console.


  2. Click Custom Domain Management on the right of the home page to bind custom domain names and set routing rules. For more information, see the next section Routing rules.


  3. Upload certificate



For more information, see Binding custom domain names.

Contact Us if you have any further questions.