In the ApsaraVideo Live console, you can create scripts based on the EdgeScript coding standard and publish the scripts to the production environment. This way, you can customize the features of ApsaraVideo Live. This topic describes how to configure EdgeScript in the ApsaraVideo Live console.
Prerequisites
The EdgeScript feature is enabled. To enable the feature, submit a ticket. For more information, see Contact us.
Background information
- Create scripts.
- Modify existing scripts.
Create a script
Log on to the ApsaraVideo Live console.
In the left-side navigation pane, click Domains. The Domain Management page appears.
Find the streaming domain that you want to configure and click Domain Settings in the Actions column.
Choose . The Staging Environment tab appears.
Click Create Script. On the Add Script page, configure a script.
NoteYou can create only one script for each domain name. If you want to create multiple scripts for a domain name, submit a ticket.
The following table describes the parameters.
Parameter
Required
Description
Script Name
Yes
Specify a name for the script. The name can contain only letters, digits, and underscores (_).
Script Code
Yes
Enter the code of the script.
Priority
Yes
Specify a priority for the script. Valid values: 0 to 99. A value of 0 specifies the highest priority, and a value of 99 specifies the lowest priority.
Run Script At
Yes
Specify the position in which you want to execute the script.
Enable
Yes
Specify whether to enable the script.
Break
No
Specify whether to skip the subsequent scripts if the current script is matched.
After you turn on Break, the subsequent scripts are skipped if the current script is matched.
Extensions
No
EdgeScript supports extensions. Only
_es_dbg=signature
is supported. This field is used to add a response header for debugging.After you configure the script, click Open Debugging Tool to perform single request testing. This operation is optional.
Configure the following parameters: Request Method, Protocol, HOST, URL, Request Header, and Request Body.
NoteYou can ping the domain name
staging.myalicdn.com
to obtain the IP address of the test node in the staging environment. Then, enter the IP address in the HOST field.Sample URL:
http://example.com/image/***.jpg
.Sample Request Header:
Accept-Encoding: gzip, deflate, br
.
Click Submit for Testing to send a request.
Receive the response.
Click Publish to Staging Environment. Test the script in the staging environment.
The IP address of the test node in the following figure is only for reference. The actual IP address of the test node in the staging environment shall prevail.
On your client, find the hosts file in the path C:\Windows\System32\drivers\etc. Add the IP address of the test node to the hosts file.
ImportantIn a Windows operating system, the path is C:\Windows\System32\drivers\etc\hosts.
In a macOS operating system, the path is /etc/hosts.
After you test the script, click Publish All Scripts to Production Environment to publish all scripts from the staging environment to the production environment.
ImportantAfter you publish the script to the production environment, the script is automatically deleted from the staging environment.
Modify an existing script
Click Roll Back Configurations in the Staging Environment to roll back configurations in the staging environment to the initial status.
Click Copy Scripts from Production Environment to copy the scripts from the production environment to the staging environment.
On the Staging Environment tab, find the script that you want to modify. Click Modify in the Actions column to modify the script.
After you modify the script, click Open Debugging Tool to perform single request testing.
Click Publish to Staging Environment. Test the script in the staging environment.
After you test the script, click Publish All Scripts to Production Environment to publish all scripts from the staging environment to the production environment.
ImportantAfter you publish the script to the production environment, the script is automatically deleted from the staging environment.