From bced1ed8b8142dbb5246e1db353b277a2b4e3a8f Mon Sep 17 00:00:00 2001 From: Andrey Voronkov Date: Sat, 11 Apr 2020 21:35:29 +0300 Subject: [PATCH] Ability to separately disable access log in http and stream contexts Two new configuration options: `disable-http-access-log` `disable-stream-access-log` Should resolve issue with enormous amount of `TCP 200` useless entries in logs Signed-off-by: Andrey Voronkov --- internal/ingress/controller/config/config.go | 13 +++++++++++-- rootfs/etc/nginx/template/nginx.tmpl | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/internal/ingress/controller/config/config.go b/internal/ingress/controller/config/config.go index b39145957fd..9325dfea75f 100644 --- a/internal/ingress/controller/config/config.go +++ b/internal/ingress/controller/config/config.go @@ -157,10 +157,19 @@ type Configuration struct { // http://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_timeout ClientBodyTimeout int `json:"client-body-timeout,omitempty"` - // DisableAccessLog disables the Access Log globally from NGINX ingress controller - //http://nginx.org/en/docs/http/ngx_http_log_module.html + // DisableAccessLog disables the Access Log globally for both HTTP and Stream contexts from NGINX ingress controller + // http://nginx.org/en/docs/http/ngx_http_log_module.html + // http://nginx.org/en/docs/stream/ngx_stream_log_module.html DisableAccessLog bool `json:"disable-access-log,omitempty"` + // DisableHTTPAccessLog disables the Access Log for http context globally from NGINX ingress controller + // http://nginx.org/en/docs/http/ngx_http_log_module.html + DisableHTTPAccessLog bool `json:"disable-http-access-log,omitempty"` + + // DisableStreamAccessLog disables the Access Log for stream context globally from NGINX ingress controller + // http://nginx.org/en/docs/stream/ngx_stream_log_module.html + DisableStreamAccessLog bool `json:"disable-stream-access-log,omitempty"` + // DisableIpv6DNS disables IPv6 for nginx resolver DisableIpv6DNS bool `json:"disable-ipv6-dns"` diff --git a/rootfs/etc/nginx/template/nginx.tmpl b/rootfs/etc/nginx/template/nginx.tmpl index 9cf9cd22dfd..974914554ef 100755 --- a/rootfs/etc/nginx/template/nginx.tmpl +++ b/rootfs/etc/nginx/template/nginx.tmpl @@ -315,7 +315,7 @@ http { default 1; } - {{ if $cfg.DisableAccessLog }} + {{ if or $cfg.DisableAccessLog $cfg.DisableHTTPAccessLog }} access_log off; {{ else }} {{ if $cfg.EnableSyslog }} @@ -684,7 +684,7 @@ stream { log_format log_stream '{{ $cfg.LogFormatStream }}'; - {{ if $cfg.DisableAccessLog }} + {{ if or $cfg.DisableAccessLog $cfg.DisableStreamAccessLog }} access_log off; {{ else }} access_log {{ $cfg.AccessLogPath }} log_stream {{ $cfg.AccessLogParams }};