In the CDN console, you can create scripts based on EdgeScript (ES) coding conventions and then publish the scripts to the production environment to configure custom CDN features. This topic describes how to configure scripts by using the console.
Procedure
- Log on to the Alibaba Cloud CDN console.
- In the left-side navigation pane, click Domain Names.
- On the Domain Names page, find the domain name that you want to manage and click Manage in the Actions column.
- Click EdgeScript.
- Create a script in the staging environment.
- Test the script in the staging environment.
Before you publish a script to the production environment, you must test the script in the staging environment. To obtain the IP address that is used to test the script in the staging environment, resolve the domain name staging.myaliCDN/DCDN.com. Then, map the IP address to the accelerated domain name on your client machine.
Add the mapping between the test IP address and the accelerated domain name to the hosts file on your client machine. The path to the hosts file is:- C:\Windows\System32\drivers\etc\hosts if your client machine runs Windows.
- /etc/hosts if your client machine runs macOS.
- After you complete the test, click Publish All Rules to Production Environment to publish the script to the production environment. Important After you publish the script to the production environment, the script is automatically deleted from the staging environment.
Roll back scripts
To clear the configurations in the staging environment and restore the staging environment to the initialized state, click Roll Back Scripts. In the message that appears, click OK.
Modify or delete scripts
If you want to add, modify, or delete a script that is published to the production environment, we recommend that you copy the script from the production environment to the staging environment, modify and test the script in the staging environment, and then publish the modified script to the production environment. Perform the following steps:
- Click Roll Back Scripts. Make sure that the staging environment is initialized to prevent unexpected interference.
- Click Copy Rules from Production Environment to copy the script from the production environment to the staging environment. This prevents inconsistencies in the script caused by manual operations.
- Add, modify, or delete the script in the staging environment.
- Click Publish to Staging Environment to publish the modified script to the staging environment. Then, test the script in the staging environment. For information about how to test the script in the staging environment, see Test scripts in the staging environment.
- After you complete the test, click Publish All Rules to Production Environment to publish the script to the production environment and check whether the script can meet your business requirements.
You can also use the EdgeScript CLI to configure scripts. For more information, see Use the EdgeScript CLI to configure scripts.