All Products
Search
Document Center

ApsaraVideo Live:Configure EdgeScript

Last Updated:Apr 07, 2024

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

Use EdgeScript to manage scripts in one of the following scenarios as needed:
  1. Create scripts.
  2. Modify existing scripts.

Create a script

  1. Log on to the ApsaraVideo Live console.

  2. In the left-side navigation pane, click Domains. The Domain Management page appears.

  3. Find the streaming domain that you want to configure and click Domain Settings in the Actions column.

    001

  4. Choose Streaming Management > EdgeScript. The Staging Environment tab appears.

  5. Click Create Script. On the Add Script page, configure a script.

    Note

    You 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.

    1. Configure the following parameters: Request Method, Protocol, HOST, URL, Request Header, and Request Body.

      Note
      • You 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.

    2. Click Submit for Testing to send a request.

    3. Receive the response.

  6. 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.测试IP

    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.

    Important
    • In a Windows operating system, the path is C:\Windows\System32\drivers\etc\hosts.

    • In a macOS operating system, the path is /etc/hosts.

  7. After you test the script, click Publish All Scripts to Production Environment to publish all scripts from the staging environment to the production environment.

    Important

    After you publish the script to the production environment, the script is automatically deleted from the staging environment.

Modify an existing script

  1. Click Roll Back Configurations in the Staging Environment to roll back configurations in the staging environment to the initial status.

  2. Click Copy Scripts from Production Environment to copy the scripts from the production environment to the staging environment.

  3. On the Staging Environment tab, find the script that you want to modify. Click Modify in the Actions column to modify the script.

  4. After you modify the script, click Open Debugging Tool to perform single request testing.

  5. Click Publish to Staging Environment. Test the script in the staging environment.

  6. After you test the script, click Publish All Scripts to Production Environment to publish all scripts from the staging environment to the production environment.

    Important

    After you publish the script to the production environment, the script is automatically deleted from the staging environment.