Need help with ngx_dynamic_upstream?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

cubicdaiya
452 Stars 103 Forks Other 78 Commits 12 Opened issues

Description

Dynamic upstream for nginx

Services available

!
?

Need anything else?

Contributors list

# 65,482
C
Perl
gcm
apns
68 commits
# 66,223
Ruby
Rails
circlec...
imagema...
2 commits
# 61,470
Elixir
Perl
Erlang
nginx
1 commit
# 400,436
Shell
Objecti...
CSS
1 commit

ngxdynamicupstream

ngx_dynamic_upstream
is the module for operating upstreams dynamically with HTTP APIs such as
ngx_http_upstream_conf
.

Requirements

ngx_dynamic_upstream
requires the
zone
directive in the
upstream
context. This directive is available in nginx-1.9.0-plus.

Status

Production ready.

Directives

dynamic_upstream

|Syntax |dynamic_upstream| |-------|----------------| |Default|-| |Context|location|

Now

ngx_dynamic_upstream
supports dynamic upstream under only
http
context.

Quick Start

upstream backends {
    zone zone_for_backends 1m;
    server 127.0.0.1:6001;
    server 127.0.0.1:6002;
    server 127.0.0.1:6003;
}

server { listen 6000;

location /dynamic {
    allow 127.0.0.1;
    deny all;
    dynamic_upstream;
}

location / {
    proxy_pass http://backends;
}

}

HTTP APIs

You can operate upstreams dynamically with HTTP APIs.

list

$ curl "http://127.0.0.1:6000/dynamic?upstream=zone_for_backends"
server 127.0.0.1:6001;
server 127.0.0.1:6002;
server 127.0.0.1:6003;
$

verbose

$ curl "http://127.0.0.1:6000/dynamic?upstream=zone_for_backends&verbose="
server 127.0.0.1:6001 weight=1 max_fails=1 fail_timeout=10;
server 127.0.0.1:6002 weight=1 max_fails=1 fail_timeout=10;
server 127.0.0.1:6003 weight=1 max_fails=1 fail_timeout=10;
$

update_parameters

$ curl "http://127.0.0.1:6000/dynamic?upstream=zone_for_backends&server=127.0.0.1:6003&weight=10&max_fails=5&fail_timeout=5"
server 127.0.0.1:6001 weight=1 max_fails=1 fail_timeout=10;
server 127.0.0.1:6002 weight=1 max_fails=1 fail_timeout=10;
server 127.0.0.1:6003 weight=10 max_fails=5 fail_timeout=5;
$

The supported parameters are blow.

  • weight
  • max_fails
  • fail_timeout

down

$ curl "http://127.0.0.1:6000/dynamic?upstream=zone_for_backends&server=127.0.0.1:6003&down="
server 127.0.0.1:6001 weight=1 max_fails=1 fail_timeout=10;
server 127.0.0.1:6002 weight=1 max_fails=1 fail_timeout=10;
server 127.0.0.1:6003 weight=1 max_fails=1 fail_timeout=10 down;
$

up

$ curl "http://127.0.0.1:6000/dynamic?upstream=zone_for_backends&server=127.0.0.1:6003&up="
server 127.0.0.1:6001 weight=1 max_fails=1 fail_timeout=10;
server 127.0.0.1:6002 weight=1 max_fails=1 fail_timeout=10;
server 127.0.0.1:6003 weight=1 max_fails=1 fail_timeout=10;
$

add

$ curl "http://127.0.0.1:6000/dynamic?upstream=zone_for_backends&add=&server=127.0.0.1:6004"
server 127.0.0.1:6001;
server 127.0.0.1:6002;
server 127.0.0.1:6003;
server 127.0.0.1:6004;
$

remove

$ curl "http://127.0.0.1:6000/dynamic?upstream=zone_for_backends&remove=&server=127.0.0.1:6003"
server 127.0.0.1:6001;
server 127.0.0.1:6002;
server 127.0.0.1:6004;
$

License

See LICENSE.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.