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 NameData TypeRequiredDescription
sslbooleanNoEnable SSL connection, default is false
disable_ssl_verifybooleanNoDisable SSL verification, default is false
enable_checkerbooleanNoEnable health check, default is false
serversarrayYesList of upstream servers
checkerobjectNoHealth check configuration, only valid when enable_checker is true

servers Configuration

Parameter NameData TypeRequiredDescription
hoststringYesServer hostname or IP address
portintegerYesServer port number

checker Configuration

The configuration contains multiple parameters defining how health checks are performed. The main parameters include:

Parameter NameData TypeDescription
typestringHealth check type, such as “tcp”, “http”, “https”
intervalintegerCheck interval
timeoutintegerTimeout duration
fallintegerConsecutive failure threshold
riseintegerConsecutive success threshold
http_req_methodstringHTTP request method
http_req_uristringHTTP request URI
valid_statusesarrayList 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

  1. Each application upstream must have a unique name.

  2. A server’s host can be an IPv4 address, IPv6 address, or domain name.

  3. The port must be a valid port number (1-65535).

  4. If a health check is enabled (enable_checker: true), a valid ‘checker’ configuration must be provided.

  5. When updating configurations, the tool compares the new and old configurations to determine if an update is necessary.

  6. When importing configurations, the tool first checks their validity before performing add or update operations.

  7. If an upstream is removed from the configuration, the tool will automatically remove it from the application.

  8. If an error occurs during configuration processing, the tool will automatically clear the changes made to maintain configuration consistency.

  9. the tool formats server information into a unified structure for better readability and portability when exporting configurations.

  10. When exporting configurations, if an application does not exist, the tool will provide a warning message.