diff --git a/README.md b/README.md index 6819c03..4357190 100644 --- a/README.md +++ b/README.md @@ -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` @@ -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 diff --git a/ngx_http_upstream_dynamic_servers.c b/ngx_http_upstream_dynamic_servers.c index 05b2889..c451107 100644 --- a/ngx_http_upstream_dynamic_servers.c +++ b/ngx_http_upstream_dynamic_servers.c @@ -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; @@ -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; @@ -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)) {