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:

ParameterData 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

ParameterData 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:

ParameterData 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

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

  1. Global upstreams are a global configuration. To maintain compatibility with multiple local configurations, delete operations are not performed when updating configurations.

  2. Each global upstream must have a unique name.

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

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

  5. If health checks are enabled (enable_checker: true), a valid ‘checker’ configuration must be provided.

  6. 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.

  7. When importing configurations, the tool first checks the configuration’s validity before performing add or update operations.

  8. When exporting configurations, the tool formats server information into a unified structure to improve the configuration’s readability and portability.