Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Defines a server for an upstream. The module adds the ability to specify a `reso
The following parameters can be used (see nginx's [server documentation](http://nginx.org/en/docs/http/ngx_http_upstream_module.html#server) for details):

`weight=number`
`max_conns=number`
`max_fails=number`
`fail_timeout=time`
`backup`
Expand All @@ -52,7 +53,7 @@ The following parameters can be used (see nginx's [server documentation](http://

# Compatibility

Tested with nginx 1.6, 1.7, 1.8, 1.9.
Tested with nginx 1.6, 1.7, 1.8, 1.9, 1.11.

## Alternatives

Expand Down
24 changes: 24 additions & 0 deletions ngx_http_upstream_dynamic_servers.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ static char * ngx_http_upstream_dynamic_server_directive(ngx_conf_t *cf, ngx_com
time_t fail_timeout;
ngx_str_t *value, s;
ngx_url_t u;
#if nginx_version >= 1011005
ngx_int_t weight, max_conns, max_fails;
#else
ngx_int_t weight, max_fails;
#endif
ngx_uint_t i;
ngx_http_upstream_server_t *us;

Expand All @@ -117,6 +121,9 @@ static char * ngx_http_upstream_dynamic_server_directive(ngx_conf_t *cf, ngx_com
value = cf->args->elts;

weight = 1;
#if nginx_version >= 1011005
max_conns = 0;
#endif
max_fails = 1;
fail_timeout = 10;

Expand All @@ -137,6 +144,23 @@ static char * ngx_http_upstream_dynamic_server_directive(ngx_conf_t *cf, ngx_com
continue;
}

#if nginx_version >= 1011005
if (ngx_strncmp(value[i].data, "max_conns=", 10) == 0) {

if (!(uscf->flags & NGX_HTTP_UPSTREAM_MAX_CONNS)) {
goto not_supported;
}

max_conns = ngx_atoi(&value[i].data[10], value[i].len - 10);

if (max_conns == NGX_ERROR) {
goto invalid;
}

continue;
}
#endif

if (ngx_strncmp(value[i].data, "max_fails=", 10) == 0) {

if (!(uscf->flags & NGX_HTTP_UPSTREAM_MAX_FAILS)) {
Expand Down