In the Dynamic Route for CDN (DCDN) console, you can create scripts based on the EdgeScript (ES) coding conventions, and publish the scripts to the production environment to customize features of DCDN. This topic describes how to use ES to create a script in the DCDN console.
- Log on to the DCDN console.
- In the left-side navigation pane, click Domain Names.
- On the Configure page, find the domain name that you want to manage and click Domain Names in the Actions column.
- Click EdgeScript.
- Create a script in the staging environment.
- On the Staging Environment tab, click Create Script and set the parameters. Note You can create only one script for each domain name. To create more scripts for a domain name, submit a ticket.
Parameter Required Description Script Name Yes Specify a name for the script. The name can contain letters, digits, and underscores (_). Script Code Yes
- You can click Use Code Template to use a code template.
- You can also directly write a script. For more information, see EdgeScript scenarios.
Priority YesSpecify a priority for the script. Valid values are 0 to 999. Priorities set for different execution positions do not affect each other.
- 0: the highest priority.
- 999: the lowest priority.
Run Script At Yes Specify the position where you want to execute the script. For more information, see Positions and priorities. Status Yes Specifies whether to enable the script. Break No Specify whether to skip the subsequent scripts if the current script is executed. After you turn on Break, the subsequent scripts are skipped if the current script is executed. Extensions No ES supports extensions. Only
_es_dbg=signatureis supported. This field enables debugging.
- Click Publish to Staging Environment.
- On the Staging Environment tab, click Create Script and set the parameters.
- Test the script in the staging environment.
You must test the script in the staging environment before you can publish it to the production environment. To obtain the IP address for testing in the staging environment, you can resolve the domain name staging.myalicdn.com. Then, add the mapping between the IP address and the accelerated domain name to the hosts file on your client machine.The path to the hosts file is:
- In a Windows operating system, the path is C:\Windows\System32\drivers\etc\hosts.
- In a macOS operating system, the path is /etc/hosts.
- Publish all scripts to the production environment. After the test is completed, click Publish All Scripts to Production Environment to publish the script to the production environment.Notice After you publish the script from the staging environment to the production environment, the script is automatically deleted from the staging environment.
- Optional:Copy scripts from the production environment.
To modify scripts that you have already published to the production environment, you must copy the scripts from the production environment to the staging environment, and then modify the scripts. You can click Copy Rules from Production Environment to copy scripts from the production environment to the staging environment.
After you copy a script from the production environment to the staging environment, you can modify the copied script in the staging environment.