Application Upstreams
Directory Structure
|-- upstreams/
|-- upstreams.yaml
|-- ...
The YAML files can contain one or more upstream configurations of the applications.
Configuration Description
Each application 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 Name | 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 Name | 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 Name | 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
app_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:
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: tcp
fall: 3
interval: 3
timeout: 1
http_req_method: GET
http_req_host: test.com
http_req_uri: /status
app_upstream_name2:
ssl: true
disable_ssl_verify: false
enable_checker: true
servers:
- host: 1.1.1.3
port: 443
checker:
type: https
interval: 3
timeout: 1
fall: 3
rise: 2
http_req_method: GET
http_req_uri: /status
valid_statuses:
- 200
- 302
This configuration defines two application upstreams, one using TCP health check and the other using HTTPS health check.
Usage Example
Update configuration to OpenResty Edge:
edge-config https://192.168.1.1 -s -t 2051e780-1897-4ea0-92b4-2c2f0169aa94 -l upstreams -i /root/oredge-configs -d test.com
Export configuration from OpenResty Edge:
edge-config -u https://192.168.1.1 -s -t 2051e780-1897-4ea0-92b4-2c2f0169aa94 -E -l upstreams -d test.com
Cleanup upstreams from OpenResty Edge:
edge-config -u https://192.168.1.1 -s -t 2051e780-1897-4ea0-92b4-2c2f0169aa94 -c -l upstreams -d test.com
The above examples all use -l upstreams
to specify that the command-line tool will operate only on configurations related to the upstreams.
Notes
Each application 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 a health check is 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.
When importing configurations, the tool first checks their validity before performing add or update operations.
If an upstream is removed from the configuration, the tool will automatically remove it from the application.
If an error occurs during configuration processing, the tool will automatically clear the changes made to maintain configuration consistency.
the tool formats server information into a unified structure for better readability and portability when exporting configurations.
When exporting configurations, if an application does not exist, the tool will provide a warning message.