Global Static Files
Directory Structure
|-- global_static_files/
|-- global_static_files.yaml
|-- files/
|-- hello/
|-- world/
|-- test.html
|-- ...
The global_static_files.yaml
file contains configuration information for global static files and directories, while the actual file contents are stored in the files/
directory.
Configuration Description
Each static file or directory configuration is an object containing the following parameters:
Parameter Name | Data Type | Required | Description |
---|---|---|---|
type | string | Yes | Type, can be “file” or “dir” |
path | string | Yes | Path of the file or directory |
name | string | Yes | Name of the file or directory |
label | string | No | Label for the file or directory |
Configuration Example
- type: dir
path: dir1
name: dir1
- type: dir
path: dir2
name: dir2
- type: dir
path: dir1/dir12
name: dir12
- type: file
path: hello.html
name: hello.html
- type: file
path: dir1/setup.sh
name: setup.sh
- type: file
path: dir1/hello.html
name: hello.html
- type: file
path: dir1/stream.pcap
name: stream.pcap
- type: archived
path: dist.tar.gz
This configuration defines multiple directories and files. The directory structure is as follows:
/
├── dir1/
│ ├── dir12/
│ ├── setup.sh
│ ├── hello.html
│ └── stream.pcap
├── dir2/
├── dist.tar.gz
└── hello.html
The file dist.tar.gz
of type archived
(first introduced in version v1.2.72
, only supports tar.gz
type compressed files) will be extracted and uploaded to the root directory /
of Edge’s global static files. You can also place it in other directories, such as dir1/
.
Assuming dist.tar.gz contains the following files:
dist/
├── static/
├── index.html
The final file structure uploaded to OpenResty Edge will be:
/
├── dir1/
│ ├── dir12/
│ ├── setup.sh
│ ├── hello.html
│ └── stream.pcap
├── dir2/
├── dist/
│ ├── static/
│ ├── index.html
└── hello.html
As you can see, dist.tar.gz has been extracted.
Usage Example
Update configuration to OpenResty Edge:
edge-config https://192.168.1.1 -s -t 2051e780-1897-4ea0-92b4-2c2f0169aa94 -l global_static_files -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_static_files
Both examples use -l global_static_files
to specify importing/exporting only global static file-related configurations.
Notes
Global static files are a global configuration. Delete operations are not performed when updating configurations to maintain compatibility with multiple local configurations.
The actual content of files is stored in the
global_static_files/files/
directory, and the directory structure should be consistent with thepath
in the configuration.When importing configurations, the tool first checks the validity of the configuration before performing add or update operations.
For file types, the tool calculates the MD5 value of the local file and compares it with the file on the server. The file is only updated when the content has changed.
For directory types, if the directory does not exist, the tool will create the corresponding directory.
When exporting configurations, the tool will download the file contents from the server to the local
global_static_files/files/
directory.The configuration file (
global_static_files.yaml
) and the actual file contents are stored and managed separately, allowing for more flexible version control and file management.only files and directories listed in
global_static_files.yaml
will be processed when updating configurations. Files on the server that are not listed in the configuration will not be automatically deleted.