http-combined-upstreams #

Nginx Combined Upstreams module

Source: upstream source

Directives

add_upstream #

syntax: add_upstream 1 arg;  ·  context: upstream

A comprehensive article discovering details of implementation of directive add_upstream which can also be regarded as a small tutorial for Nginx modules development. 2. nginx upstrand to configure super-layers of upstreams.

combine_server_singlets #

syntax: combine_server_singlets no args;  ·  context: upstream

Directive combine_server_singlets in upstream u1 generates two singlet upstreams u1_single_1 and u1_single_2 to inhabit upstrand us1.

dynamic_upstrand #

syntax: dynamic_upstrand 2+ args;  ·  context: server, location, location-if

Additionally, directive dynamic_upstrand is introduced for choosing upstrands in run-time.

extend_single_peers #

syntax: extend_single_peers no args;  ·  context: upstream

Directive extend_single_peers ----------------------------- Peers in upstreams fail according to the rules listed in directive proxy_next_upstream.

upstrand #

syntax: upstrand 1 arg;  ·  context: http

Block upstrand -------------- Is aimed to configure a super-layer of upstreams that do not lose their identities.

Example

# this nginx configuration file is for demonstration purpose only

user                    nobody;
worker_processes        1;

events {
    worker_connections  1024;
}

http {
    default_type        application/octet-stream;
    sendfile            on;

    log_format          fmt '$remote_addr [$time_local]\n'
                            '>>> [path]          $upstrand_path\n'
                            '>>> [addr]          $upstrand_addr\n'
                            '>>> [response time] $upstrand_response_time\n'
                            '>>> [status]        $upstrand_status';

    upstream u1 {
        server localhost:8020;
    }
    upstream u2 {
        server localhost:8030;
    }
    upstream ucombined {
        server localhost:8030;
        add_upstream u1;
        add_upstream u2 backup;
    }
    upstream u3 {
        server localhost:8020;
        server localhost:8030;
        combine_server_singlets;
        combine_server_singlets byname;
        combine_server_singlets _tmp_ 2;
    }
    upstream u4 {
        server localhost:8020;
        server localhost:8030;
        combine_server_singlets _single_ nobackup;
    }

    upstream u01 {
        # to test next_upstream_statuses error set port 8140
        server localhost:8040;
    }
    upstream u02 {
        # to test next_upstream_statuses error set port 8150
        server localhost:8050;
    }
    upstream b01 {
        server localhost:8060;
    }
    upstream b02 {
        server localhost:8070;
    }

    upstrand us1 {
        upstream ~^u0 blacklist_interval=60s;
        upstream b01 backup;
        order start_random;
        next_upstream_statuses error timeout non_idempotent 204 5xx;
        next_upstream_timeout 60s;
        #next_upstream_statuses 200 204 5xx;
        #next_upstream_statuses error timeout;
    }
    upstrand us2 {
        upstream ~^u0;
        upstream b02 backup;
        order start_random;
        next_upstream_statuses 5xx;
        intercept_statuses 5xx /Internal/failover;
    }
    upstrand us4 {
        upstream ~^u4_single_ blacklist_interval=60s;
        order per_request;
        next_upstream_statuses error timeout non_idempotent 5xx;
        intercept_statuses 5xx /Internal/failover;
    }

    proxy_read_timeout 5s;
    proxy_intercept_errors on;
    #proxy_next_upstream_tries 1;

    server {
        listen       8010;
        server_name
…

↑ back to index