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 <voronkovaa@gmail.com>
This commit is contained in:
Andrey Voronkov 2020-04-11 21:35:29 +03:00
parent 147bdf5f72
commit 0c4e5e1346
2 changed files with 13 additions and 4 deletions

View file

@ -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"`

View file

@ -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 }};