summaryrefslogtreecommitdiffhomepage
path: root/src/http/modules/ngx_http_limit_conn_module.c
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2013-03-18 14:50:29 +0000
committerMaxim Dounin <mdounin@mdounin.ru>2013-03-18 14:50:29 +0000
commitd7db87e6d98c0f84b40fecdd49f68bbc3c934ebb (patch)
tree04f61dfb41736c0a4967cb1a6d81441d41dc75ea /src/http/modules/ngx_http_limit_conn_module.c
parent5a7661e5817532f5e9b08109e9cbc9915d2096f9 (diff)
downloadnginx-d7db87e6d98c0f84b40fecdd49f68bbc3c934ebb.tar.gz
nginx-d7db87e6d98c0f84b40fecdd49f68bbc3c934ebb.tar.bz2
The limit_req_status and limit_conn_status directives.
Patch by Nick Marden, with minor changes.
Diffstat (limited to 'src/http/modules/ngx_http_limit_conn_module.c')
-rw-r--r--src/http/modules/ngx_http_limit_conn_module.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/http/modules/ngx_http_limit_conn_module.c b/src/http/modules/ngx_http_limit_conn_module.c
index e82ca493d..7f0eea7ab 100644
--- a/src/http/modules/ngx_http_limit_conn_module.c
+++ b/src/http/modules/ngx_http_limit_conn_module.c
@@ -40,6 +40,7 @@ typedef struct {
typedef struct {
ngx_array_t limits;
ngx_uint_t log_level;
+ ngx_uint_t status_code;
} ngx_http_limit_conn_conf_t;
@@ -74,6 +75,11 @@ static ngx_conf_enum_t ngx_http_limit_conn_log_levels[] = {
};
+static ngx_conf_num_bounds_t ngx_http_limit_conn_status_bounds = {
+ ngx_conf_check_num_bounds, 400, 599
+};
+
+
static ngx_command_t ngx_http_limit_conn_commands[] = {
{ ngx_string("limit_conn_zone"),
@@ -104,6 +110,13 @@ static ngx_command_t ngx_http_limit_conn_commands[] = {
offsetof(ngx_http_limit_conn_conf_t, log_level),
&ngx_http_limit_conn_log_levels },
+ { ngx_string("limit_conn_status"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_limit_conn_conf_t, status_code),
+ &ngx_http_limit_conn_status_bounds },
+
ngx_null_command
};
@@ -206,7 +219,7 @@ ngx_http_limit_conn_handler(ngx_http_request_t *r)
if (node == NULL) {
ngx_shmtx_unlock(&shpool->mutex);
ngx_http_limit_conn_cleanup_all(r->pool);
- return NGX_HTTP_SERVICE_UNAVAILABLE;
+ return lccf->status_code;
}
lc = (ngx_http_limit_conn_node_t *) &node->color;
@@ -231,7 +244,7 @@ ngx_http_limit_conn_handler(ngx_http_request_t *r)
&limits[i].shm_zone->shm.name);
ngx_http_limit_conn_cleanup_all(r->pool);
- return NGX_HTTP_SERVICE_UNAVAILABLE;
+ return lccf->status_code;
}
lc->conn++;
@@ -467,6 +480,7 @@ ngx_http_limit_conn_create_conf(ngx_conf_t *cf)
*/
conf->log_level = NGX_CONF_UNSET_UINT;
+ conf->status_code = NGX_CONF_UNSET_UINT;
return conf;
}
@@ -483,6 +497,8 @@ ngx_http_limit_conn_merge_conf(ngx_conf_t *cf, void *parent, void *child)
}
ngx_conf_merge_uint_value(conf->log_level, prev->log_level, NGX_LOG_ERR);
+ ngx_conf_merge_uint_value(conf->status_code, prev->status_code,
+ NGX_HTTP_SERVICE_UNAVAILABLE);
return NGX_CONF_OK;
}