From 14ff3d4f87c049ff4446efe067fbfe85d5ae18ab Mon Sep 17 00:00:00 2001 From: Vladimir Homutov Date: Thu, 18 Jun 2015 14:17:30 +0300 Subject: Stream: connection limiting module. stream { limit_conn_zone $binary_remote_addr zone=perip:1m; limit_conn_log_level error; server { ... limit_conn perip 1; } } --- src/stream/ngx_stream_handler.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/stream/ngx_stream_handler.c') diff --git a/src/stream/ngx_stream_handler.c b/src/stream/ngx_stream_handler.c index e4538b241..7b635fa4c 100644 --- a/src/stream/ngx_stream_handler.c +++ b/src/stream/ngx_stream_handler.c @@ -147,6 +147,15 @@ ngx_stream_init_connection(ngx_connection_t *c) cmcf = ngx_stream_get_module_main_conf(s, ngx_stream_core_module); + if (cmcf->limit_conn_handler) { + rc = cmcf->limit_conn_handler(s); + + if (rc != NGX_DECLINED) { + ngx_stream_close_connection(c); + return; + } + } + if (cmcf->access_handler) { rc = cmcf->access_handler(s); -- cgit