• Stars
    star
    500
  • Rank 85,491 (Top 2 %)
  • Language
    C
  • License
    Other
  • Created about 9 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Dynamic upstream for nginx

ngx_dynamic_upstream

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.

More Repositories

1

ngx_small_light

Dynamic Image Transformation Module For nginx.
C
472
star
2

nginx-build

Seamless nginx builder
Go
400
star
3

dtl

diff template library written by C++
C++
267
star
4

slackboard

A slack proxy server
Go
171
star
5

onp

The implementations of "An O(NP) Sequence Comparison Algorithm"
JavaScript
114
star
6

cachectl

Page cache controller for regular file in Go
Go
102
star
7

gonp

diff algorithm in Go
Go
45
star
8

mpool

memory pool implimentation by C with C99 style
C
33
star
9

mruby_nginx_module

Embed mruby into nginx
C
33
star
10

neoagent

A Yet Another Memcached Protocol Proxy Server
C
31
star
11

libngxcore

libngxcore is the library built from nginx core APIs.
C
26
star
12

dtl-legacy

diff template library written by C++ (left for old commit histrories)
C++
22
star
13

ngx_http_hello_world

Hello, World with nginx
C
20
star
14

ngx_dosdetector

nginx module for detecting Dos attacks
C
17
star
15

bms

Boyer-Moore search algorithm in Go
Go
14
star
16

ngx_access_token

A porting of mod_access_token for nginx
C
11
star
17

fnv

fnv is the FNV hash table implimentation written by C with C99 style
C
8
star
18

node-dtl

diff template library binding for node.js
C++
7
star
19

ngx_info

ngx_info provides HTTP interface for checking nginx information.
C
6
star
20

ngxmodgen-ruby

The code generator for nginx module
Ruby
6
star
21

tree

various tree algorithms
C
5
star
22

ngx_bumpylife

ngx_bumpylife sets the randomized limit of requests to be processed for each worker process.
C
5
star
23

ngx_http_fizzbuzz_module

FizzBuzz with Nginx
C
3
star
24

mlist

memory list
C
2
star
25

nwcagen

worker_cpu_affinity configuration generator for nginx.
Go
2
star
26

sort

various sort algorithms
Lua
2
star
27

python-q4m

Q4M operation wrapper
Python
2
star
28

ngx_dummy_filter_module

dummy filter module for Nginx
C
2
star
29

list

various list implementations by C with C99 style
C
1
star
30

talks

Go
1
star
31

zsh_completions

command completions for zsh
1
star
32

mackerel-plugin-nginx-cache

mackerel plugin for nginx cache usage
Go
1
star
33

fluent-plugin-slackboard

Fluentd plugin for proxing message to slackboard.
Ruby
1
star
34

gip

The CLI-tool to check whether given CIDR includes given IP
Go
1
star
35

stk

stk is the simple vector implementation.
C
1
star