Merge pull request #255 from rikatz/nginx-disable-access-log
Adds support for disabling access_log globally
This commit is contained in:
commit
9f83100dcc
4 changed files with 19 additions and 0 deletions
|
@ -188,6 +188,9 @@ Setting at least one code also enables [proxy_intercept_errors](http://nginx.org
|
||||||
Example usage: `custom-http-errors: 404,415`
|
Example usage: `custom-http-errors: 404,415`
|
||||||
|
|
||||||
|
|
||||||
|
**disable-access-log:** Disables the Access Log from the entire Ingress Controller. This is 'false' by default.
|
||||||
|
|
||||||
|
|
||||||
**enable-dynamic-tls-records:** Enables dynamically sized TLS records to improve time-to-first-byte. Enabled by default. See [CloudFlare's blog](https://blog.cloudflare.com/optimizing-tls-over-tcp-to-reduce-latency) for more information.
|
**enable-dynamic-tls-records:** Enables dynamically sized TLS records to improve time-to-first-byte. Enabled by default. See [CloudFlare's blog](https://blog.cloudflare.com/optimizing-tls-over-tcp-to-reduce-latency) for more information.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,10 @@ type Configuration struct {
|
||||||
// http://nginx.org/en/docs/http/ngx_http_core_module.html#client_header_buffer_size
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#client_header_buffer_size
|
||||||
ClientHeaderBufferSize string `json:"client-header-buffer-size"`
|
ClientHeaderBufferSize string `json:"client-header-buffer-size"`
|
||||||
|
|
||||||
|
// DisableAccessLog disables the Access Log globally from NGINX ingress controller
|
||||||
|
//http://nginx.org/en/docs/http/ngx_http_log_module.html
|
||||||
|
DisableAccessLog bool `json:"disable-access-log,omitempty"`
|
||||||
|
|
||||||
// EnableSPDY enables spdy and use ALPN and NPN to advertise the availability of the two protocols
|
// EnableSPDY enables spdy and use ALPN and NPN to advertise the availability of the two protocols
|
||||||
// https://blog.cloudflare.com/open-sourcing-our-nginx-http-2-spdy-code
|
// https://blog.cloudflare.com/open-sourcing-our-nginx-http-2-spdy-code
|
||||||
// By default this is enabled
|
// By default this is enabled
|
||||||
|
@ -233,6 +237,7 @@ type Configuration struct {
|
||||||
func NewDefault() Configuration {
|
func NewDefault() Configuration {
|
||||||
cfg := Configuration{
|
cfg := Configuration{
|
||||||
ClientHeaderBufferSize: "1k",
|
ClientHeaderBufferSize: "1k",
|
||||||
|
DisableAccessLog: false,
|
||||||
EnableDynamicTLSRecords: true,
|
EnableDynamicTLSRecords: true,
|
||||||
EnableSPDY: false,
|
EnableSPDY: false,
|
||||||
ErrorLogLevel: errorLevel,
|
ErrorLogLevel: errorLevel,
|
||||||
|
|
|
@ -39,12 +39,14 @@ func TestMergeConfigMapToStruct(t *testing.T) {
|
||||||
"proxy-send-timeout": "2",
|
"proxy-send-timeout": "2",
|
||||||
"skip-access-log-urls": "/log,/demo,/test",
|
"skip-access-log-urls": "/log,/demo,/test",
|
||||||
"use-proxy-protocol": "true",
|
"use-proxy-protocol": "true",
|
||||||
|
"disable-access-log": "true",
|
||||||
"use-gzip": "true",
|
"use-gzip": "true",
|
||||||
"enable-dynamic-tls-records": "false",
|
"enable-dynamic-tls-records": "false",
|
||||||
"gzip-types": "text/html",
|
"gzip-types": "text/html",
|
||||||
}
|
}
|
||||||
def := config.NewDefault()
|
def := config.NewDefault()
|
||||||
def.CustomHTTPErrors = []int{300, 400}
|
def.CustomHTTPErrors = []int{300, 400}
|
||||||
|
def.DisableAccessLog = true
|
||||||
def.SkipAccessLogURLs = []string{"/log", "/demo", "/test"}
|
def.SkipAccessLogURLs = []string{"/log", "/demo", "/test"}
|
||||||
def.ProxyReadTimeout = 1
|
def.ProxyReadTimeout = 1
|
||||||
def.ProxySendTimeout = 2
|
def.ProxySendTimeout = 2
|
||||||
|
|
|
@ -87,7 +87,11 @@ http {
|
||||||
default 1;
|
default 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{{ if $cfg.DisableAccessLog }}
|
||||||
|
access_log off;
|
||||||
|
{{ else }}
|
||||||
access_log /var/log/nginx/access.log upstreaminfo if=$loggable;
|
access_log /var/log/nginx/access.log upstreaminfo if=$loggable;
|
||||||
|
{{ end }}
|
||||||
error_log /var/log/nginx/error.log {{ $cfg.ErrorLogLevel }};
|
error_log /var/log/nginx/error.log {{ $cfg.ErrorLogLevel }};
|
||||||
|
|
||||||
{{ buildResolvers $cfg.Resolver }}
|
{{ buildResolvers $cfg.Resolver }}
|
||||||
|
@ -424,7 +428,12 @@ stream {
|
||||||
|
|
||||||
log_format log_stream '$remote_addr [$time_local] $protocol [$ssl_preread_server_name] [$stream_upstream] $status $bytes_sent $bytes_received $session_time';
|
log_format log_stream '$remote_addr [$time_local] $protocol [$ssl_preread_server_name] [$stream_upstream] $status $bytes_sent $bytes_received $session_time';
|
||||||
|
|
||||||
|
{{ if $cfg.DisableAccessLog }}
|
||||||
|
access_log off;
|
||||||
|
{{ else }}
|
||||||
access_log /var/log/nginx/access.log log_stream;
|
access_log /var/log/nginx/access.log log_stream;
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
error_log /var/log/nginx/error.log;
|
error_log /var/log/nginx/error.log;
|
||||||
|
|
||||||
# configure default backend for SSL
|
# configure default backend for SSL
|
||||||
|
|
Loading…
Reference in a new issue