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.
For example, assuming that you have a website with a domain name of
api.app.com. 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|| || |
|Access phase|| || |
Build a web server based on HTTP triggers in advance. For more information about building a web server, see Tutorial: HTTP triggers.
Obtain or transfer the ICP registration for the domain names through Alibaba Cloud. For more information about ICP registration, see ICP registration guide.
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
app.com, your account ID is 12345, and your Function Compute service is deployed in the China (Shanghai) region, then you must set the CNAME of
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
service1by the request path
“/a”and trigger the execution of
service2by the request path
Only functions that have HTTP triggers configured can be triggered for execution through custom domain names.
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:
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.
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/* are mapped to s2/f2. In this case, both
/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
api.app.com, and the routing rules are as follows:
The matching results are as follows:
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.
Log on to the Go to the Function Compute console.
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.
For more information, see Binding custom domain names.
Contact Us if you have any further questions.