tencent cloud

Serverless Cloud Function

Release Notes and Announcements
Release Notes
Announcements
User Guide
Product Introduction
Overview
Related Concepts
How It Works
Strengths
Scenarios
Related Products
Purchase Guide
Billing Overview
Billing Mode
Billable Items and Billing Modes
Function Computing Power Support
Free Tier
SCF Pricing
Billing Example
Payment Overdue
Getting Started
Creating Event Function in Console
User Guide
Quota Management
Managing Functions
Web Function Management
Log Management
Concurrence Management
Trigger Management
Function URL
A Custom Domain Name
Version Management
Alias Management
Permission Management
Running Instance Management
Plugin Management
Managing Monitors and Alarms
Network Configuration
Layer Management
Execution Configuration
Extended Storage Management
DNS Caching Configuration
Resource Managed Mode Management
Near-Offline Resource Hosting Model
Workflow
Triggers
Trigger Overview
Trigger Event Message Structure Summary
API Gateway Trigger
COS Trigger
CLS Trigger
Timer Trigger
CKafka Trigger
Apache Kafka Trigger
MQTT Trigger
Trigger Configuration Description
MPS Trigger
CLB Trigger Description
TencentCloud API Trigger
Development Guide
Basic Concepts
Testing a Function
Environment Variables
Dependency Installation
Using Container Image
Error Types and Retry Policies
Dead Letter Queue
Connecting SCF to Database
Automated Deployment
Cloud Function Status Code
Common Errors and Solutions
Developer Tools
Serverless Web IDE
Calling SDK Across Functions
Third-Party Tools
Code Development
Python
Node.js
Golang
PHP
Java
Custom Runtime
Deploying Image as Function
Web Framework Development
Deploying Framework on Command Line
Quickly Deploying Egg Framework
Quickly Deploying Express Framework
Quickly Deploying Flask Framework
Quickly Deploying Koa Framework
Quickly Deploying Laravel Framework
Quickly Deploying Nest.js Framework
Quickly Deploying Next.js Framework
Quickly Deploying Nuxt.js Framework
Quickly Deploying Django Framework
Use Cases
Overview
Solutions with Tencent Cloud Services
Business Development
TRTC Practices
COS Practices
CKafka Practice
CLS
CLB Practice
MPS
CDN
CDWPG
VOD
SMS
ES
Scheduled Task
Video Processing
Success Stories
Tencent Online Education
Online Video Industry
Tencent Online Education
Best Practice of Tencent IEG Going Global
API Documentation
History
Introduction
API Category
Making API Requests
Other APIs
Namespace APIs
Layer Management APIs
Async Event Management APIs
Trigger APIs
Function APIs
Function and Layer Status Description
Data Types
Error Codes
SDK Documentation
FAQs
General
Web Function
Billing FAQs
Network FAQs
Log FAQs
SCF utility class
Event Handling FAQs
API Gateway Trigger FAQs
Related Agreement
Service Level Agreement
Contact Us
Glossary

Configuring a Custom Domain Name

PDF
Focus Mode
Font Size
Last updated: 2025-09-25 14:12:59

Feature Overview

The function platform now supports the Custom Domain Name feature, allowing users to access your functions through a browser or other terminal devices.
By adding a custom domain name, you can point it to any function with the function URL enabled or use path mapping to point to multiple functions. Additionally, you can enable options like HTTPS protocol and WAF for the domain name to ensure its security.

Implementation Principle of Accessing Functions via Custom Domain Name

The function platform assigns a CNAME to each account in each region, with the following format:
<appid>.<region>.tencentscf.com
For example, if your custom domain name is test.com, you add a DNS record with your DNS provider to point to this domain name and configure the path mapping to the specified function on the function platform. When users access the specified path of your custom domain name test.com, the DNS resolution guides them to the function platform through the CNAME, and the request is ultimately routed to the corresponding function via path mapping. The function processes the request and returns the result to the user.

Prerequisites

When the public network services are provided in the Chinese Mainland, you need to register your domain name according to national laws and regulations before binding it to the service, ensuring that your users can access the service through your domain name. Custom domain names bound to functions in Hong Kong (China) and overseas regions do not require registration.

Directions

Step 1: Adding a Custom Domain Name

1. Log in to the Function Service Console.
2. In the left sidebar, choose Custom Domain, then click Create custom domain. as shown in the figure below:
Note:
Domain names have regional attributes and can only point to functions within the same region.



3. In Create custom domain, enter the custom domain name that has been registered. Single domain names, such as test.com, are supported, while wildcard domain names, such as *.test.com, are not supported at this time. As shown in the figure below:



4. In the pop-up window, obtain the Public Network CNAME or Private Network CNAME, then go to your DNS resolution platform and map your custom domain name to this CNAME. After confirming the resolution is complete, proceed to the next step.



The CNAME formats are as follows:
Public Network CNAME:<appid>.<region>.tencentscf.com Example:123456.ap-guangzhou.tencentscf.com
Private Network CNAME:<appid>.in.<region>.tencentscf.com Example:123456.in.ap-guangzhou.tencentscf.com

Step 2: Adding Path Mapping

You can map different paths to different functions, allowing different request paths to trigger the execution of different functions. By default, you only need to configure the root path (/) to map to the specified version or alias of a function.




Path Mapping Matching Rules

Exact Path:
The requested path needs to match the configured path exactly in order to trigger the corresponding function.
For example, if the configured path is /a/, with the namespace n1, the function f1, and version 1, then only requests from the path /a/ will trigger version 1 of the f1 function. Requests from /a or /a/b will not trigger version 1 of the f1 function.
For example, if the configured path is /a, with the namespace n1, the function f1, and version 1, then only requests from the path /a will trigger version 1 of the f1 function. Requests from /a/ will not trigger version 1 of the f1 function.
Fuzzy Path:
The wildcard (*) can be used to set the path, but it can only be placed at the end of the path; the longest prefix matching principle applies.
For example, if the configured path is /xxx/*, with the namespace n2, the function f2, and version 1, then any request with the path prefix /xxx/ (such as /xxx/a or /xxx/b/c/d) will trigger version 1 of the f2 function.

Path Rewrite Policy

When you point a sub-path to a function, the path in the request received by the function will include that sub-path by default. For example, the behavior in the following two scenes is:
1. When the exact path /home points to function a, and abc.test.com/home is accessed, the path in the request received by function a will be /home.
2. When the fuzzy path /test/* points to function b, and abc.test.com/test/login is accessed, the path in the request received by function b will be /test/login.
If you want the function to receive requests without the sub-path, you can enable the Rewrite Policy. After the Rewrite Policy is enabled, the behavior for the above two scenes is:
1. When the exact path /home points to function a, and abc.test.com/home is accessed, the path in the request received by function a will be /.
2. When the fuzzy path /test/* points to function b, and abc.test.com/test/login is accessed, the path in the request received by function b will be /login.




Step 3: (Optional) HTTPS Settings

You can also choose to enable the HTTPS protocol for accessing the custom domain name.



After enabling it, you need to select a certificate that matches the domain name from the SSL Certificate Service to complete the configuration. If the certificate dropdown list is empty, it indicates you do not yet have a matching certificate for the domain name in the SSL Certificate Service, and you should first go to the SSL Certificate Service to upload or purchase a certificate.
Once the configuration is complete, the domain name can be accessed via either the HTTP or HTTPS protocol.
You can also enable the Force HTTPS option. Once it is enabled, only HTTPS protocol access to the domain name is supported, and all HTTP access requests will be redirected to HTTPS with a 301 status code.

Step 4. (Optional) WAF Settings

You can also choose to enable WAF, which provides protection against bot attacks, crawlers, and malicious registrations, effectively ensuring the secure and stable operation of your business. This feature will incur some fees. For details, see WAF.
The configuration steps are as follows:
1. Log in to the Tencent Cloud Console.
2. Go to the WAF purchase page.
3. On the WAF purchase page, select CLB Instance as shown in the figure below:



4. After completing the purchase, return to the SCF console, go to the Custom Domain Name configuration page, and select Enable WAF. Then, select the corresponding instance ID from the WAF instance dropdown list.




Step 5. Verifying the Custom Domain Name

You can choose to test through a browser or by using the curl command in the command line. After accessing the custom domain name, verify whether the specified function has been called.
Browser Test:
i. Open a browser and enter your custom domain name, such as https://abc.test.com.
ii. Check whether the specified function is correctly called and returns the expected result.
Command Line curl Test:
curl -v https://abc.test.com
Check the output to verify whether the specified function is correctly called and returns the expected result.


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback