Global Upstreams
Directory Structure
|-- global_upstreams/
|-- global_upstreams.yaml
|-- ...
The YAML files can contain one or more global upstream configurations.
Configuration Description
Each global upstream configuration is a key-value pair, where the key is the upstream name, and the value is an object containing the following parameters:
Parameter | Data Type | Required | Description |
---|---|---|---|
ssl | boolean | No | Enable SSL connection, default is false |
disable_ssl_verify | boolean | No | Disable SSL verification, default is false |
enable_checker | boolean | No | Enable health check, default is false |
servers | array | Yes | List of upstream servers |
checker | object | No | Health check configuration, only valid when enable_checker is true |
servers Configuration
Parameter | Data Type | Required | Description |
---|---|---|---|
host | string | Yes | Server hostname or IP address |
port | integer | Yes | Server port number |
checker Configuration
The configuration contains multiple parameters defining how health checks are performed. The main parameters include:
Parameter | Data Type | Description |
---|---|---|
type | string | Health check type, such as “tcp”, “http”, “https” |
interval | integer | Check interval |
timeout | integer | Timeout duration |
fall | integer | Consecutive failure threshold |
rise | integer | Consecutive success threshold |
http_req_method | string | HTTP request method |
http_req_uri | string | HTTP request URI |
valid_statuses | array | List of valid HTTP status codes |
Configuration Example
global_upstream_name1:
ssl: false
disable_ssl_verify: false
enable_checker: true
servers:
- host: 1.1.1.1
port: 80
- host: 1.1.1.2
port: 80
checker:
interval_unit: sec
http_req_method: GET
ssl_verify: true
concurrency: 5
always_check: false
report_interval_unit: min
rise: 2
timeout: 1
interval: 3
type: tcp
http_ver: '1.0'
report_interval: 3
fall: 3
global_upstream_name2:
ssl: true
disable_ssl_verify: false
enable_checker: true
servers:
- host: 1.1.1.3
port: 443
checker:
user_agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0
valid_statuses:
- 200
- 302
rise: 2
type: https
fall: 3
ssl_verify: true
interval_unit: sec
http_req_method: GET
concurrency: 5
http_req_host: test.com
resp_body_match: abc
timeout: 1
interval: 3
always_check: false
http_ver: '1.0'
http_req_uri: /status
report_interval_unit: min
global_upstream_name3:
ssl: false
disable_ssl_verify: false
enable_checker: false
servers:
- host: 1.1.1.1
port: 80
- host: 1.1.1.2
port: 80
This configuration defines three global upstreams with different settings and health check configurations.
Usage Example
Update configuration to OpenResty Edge:
edge-config https://192.168.1.1 -s -t 2051e780-1897-4ea0-92b4-2c2f0169aa94 -l global_upstreams -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_upstreams
Both examples use -l global_upstreams
to specify importing/exporting only global upstream related configurations.
Notes
Global upstreams are a global configuration. To maintain compatibility with multiple local configurations, delete operations are not performed when updating configurations.
Each global upstream must have a unique name.
A server’s
host
can be an IPv4 address, IPv6 address, or domain name.The
port
must be a valid port number (1-65535).If health checks are enabled (
enable_checker: true
), a valid ‘checker’ configuration must be provided.When updating configurations, the tool compares the new and old configurations to determine if an update is necessary. If there are changes, an update operation will be performed.
When importing configurations, the tool first checks the configuration’s validity before performing add or update operations.
When exporting configurations, the tool formats server information into a unified structure to improve the configuration’s readability and portability.