diff options
author | Roman Arutyunyan <arut@nginx.com> | 2024-06-27 17:29:56 +0400 |
---|---|---|
committer | Roman Arutyunyan <arut@nginx.com> | 2024-06-27 17:29:56 +0400 |
commit | 788e462c5b81f5f1aee475488e10f01680c530e9 (patch) | |
tree | e4df984b2622e4a5a68c4c2ab7f8bd8870c41e20 /src/stream/ngx_stream_core_module.c | |
parent | e734df6664e70f118ca3140bcef6d4f1750fa8fa (diff) | |
download | nginx-788e462c5b81f5f1aee475488e10f01680c530e9.tar.gz nginx-788e462c5b81f5f1aee475488e10f01680c530e9.zip |
Stream: allow servers with no handler.
Previously handlers were mandatory. However they are not always needed.
For example, a server configured with ssl_reject_handshake does not need a
handler. Such servers required a fake handler to pass the check. Now handler
absence check is moved to runtime. If handler is missing, the connection is
closed with 500 code.
Diffstat (limited to 'src/stream/ngx_stream_core_module.c')
-rw-r--r-- | src/stream/ngx_stream_core_module.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/stream/ngx_stream_core_module.c b/src/stream/ngx_stream_core_module.c index 3093963b7..40951c291 100644 --- a/src/stream/ngx_stream_core_module.c +++ b/src/stream/ngx_stream_core_module.c @@ -458,6 +458,13 @@ ngx_stream_core_content_phase(ngx_stream_session_t *s, return NGX_OK; } + if (cscf->handler == NULL) { + ngx_log_debug0(NGX_LOG_DEBUG_STREAM, c->log, 0, + "no handler for server"); + ngx_stream_finalize_session(s, NGX_STREAM_INTERNAL_SERVER_ERROR); + return NGX_OK; + } + cscf->handler(s); return NGX_OK; @@ -734,13 +741,6 @@ ngx_stream_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) conf->resolver = prev->resolver; } - if (conf->handler == NULL) { - ngx_log_error(NGX_LOG_EMERG, cf->log, 0, - "no handler for server in %s:%ui", - conf->file_name, conf->line); - return NGX_CONF_ERROR; - } - if (conf->error_log == NULL) { if (prev->error_log) { conf->error_log = prev->error_log; |