Global Page Templates

Directory Structure

|-- global_page_templates/
  |-- global_page_templates.yaml
  |-- ...

The YAML files can contain one or more global page templates.

Configuration Description

Each global page template is an object containing the following parameters:

Parameter NameData TypeRequiredDescription
namestringYesThe name of the page template, which is also its unique identifier
contentstringYesThe HTML content of the page template

Configuration Example

- name: page403
  content: |
    <!doctype html>
    <html>
    <head>
      <title>403 For Bidden</title>
    </head>
    <body>
      ::CLIENT_IP::
    </body>
    </html>

- name: page404
  content: |
    <!doctype html>
    <html>
    <head>
      <title>404 Not Found</title>
    </head>
    <body>
      ::CLIENT_IP::
    </body>
    </html>

This configuration defines two global page templates for 403 and 404 error pages respectively.

Usage Example

Update configuration to OpenResty Edge:

edge-config https://192.168.1.1 -s -t 2051e780-1897-4ea0-92b4-2c2f0169aa94 -l global_page_templates -i /root/oredge-configs

Export configuration from OpenResty Edge:

edge-config -u https://192.168.1.1 -s -t 2051e780-1897-4ea0-92b4-2c2f0169aa94 -E -l global_page_templates

Both examples use -l global_page_templates to specify importing/exporting only the global page template related configurations.

Notes

  1. Global page templates are a global configuration. Delete operations are not performed when updating configurations to maintain compatibility with multiple local configurations.

  2. Each global page template must have a unique name.

  3. Template content can include special placeholders, such as ::CLIENT_IP::, which will be replaced with corresponding values when actually used.

  4. When updating configurations, the tool compares new and old configurations to determine if an update is needed. If the template content has changed, an update operation will be performed.

  5. When importing configurations, the tool first checks the validity of the configuration to ensure each template contains name and content fields.

  6. When exporting configurations, the tool formats the YAML content to maintain the readability of template content.

  7. Page templates can be referenced by other features, such as error page configurations, custom responses, etc.