Merge pull request #3702 from stamm/access_logs_params
Add params for access log
This commit is contained in:
commit
bd248250be
4 changed files with 18 additions and 2 deletions
|
@ -30,6 +30,7 @@ The following table shows a configuration option's name, type, and the default v
|
||||||
|[add-headers](#add-headers)|string|""|
|
|[add-headers](#add-headers)|string|""|
|
||||||
|[allow-backend-server-header](#allow-backend-server-header)|bool|"false"|
|
|[allow-backend-server-header](#allow-backend-server-header)|bool|"false"|
|
||||||
|[hide-headers](#hide-headers)|string array|empty|
|
|[hide-headers](#hide-headers)|string array|empty|
|
||||||
|
|[access-log-params](#access-log-params)|string|""|
|
||||||
|[access-log-path](#access-log-path)|string|"/var/log/nginx/access.log"|
|
|[access-log-path](#access-log-path)|string|"/var/log/nginx/access.log"|
|
||||||
|[error-log-path](#error-log-path)|string|"/var/log/nginx/error.log"|
|
|[error-log-path](#error-log-path)|string|"/var/log/nginx/error.log"|
|
||||||
|[enable-dynamic-tls-records](#enable-dynamic-tls-records)|bool|"true"|
|
|[enable-dynamic-tls-records](#enable-dynamic-tls-records)|bool|"true"|
|
||||||
|
@ -169,6 +170,13 @@ _**default:**_ empty
|
||||||
_References:_
|
_References:_
|
||||||
[http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_hide_header](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_hide_header)
|
[http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_hide_header](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_hide_header)
|
||||||
|
|
||||||
|
## access-log-params
|
||||||
|
|
||||||
|
Additional params for access_log. For example, buffer=16k, gzip, flush=1m
|
||||||
|
|
||||||
|
_References:_
|
||||||
|
[http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log](http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log)
|
||||||
|
|
||||||
## access-log-path
|
## access-log-path
|
||||||
|
|
||||||
Access log path. Goes to `/var/log/nginx/access.log` by default.
|
Access log path. Goes to `/var/log/nginx/access.log` by default.
|
||||||
|
|
|
@ -94,6 +94,11 @@ type Configuration struct {
|
||||||
// By default this is disabled
|
// By default this is disabled
|
||||||
AllowBackendServerHeader bool `json:"allow-backend-server-header"`
|
AllowBackendServerHeader bool `json:"allow-backend-server-header"`
|
||||||
|
|
||||||
|
// AccessLogParams sets additionals params for access_log
|
||||||
|
// http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
|
||||||
|
// By default it's empty
|
||||||
|
AccessLogParams string `json:"access-log-params,omitempty"`
|
||||||
|
|
||||||
// AccessLogPath sets the path of the access logs if enabled
|
// AccessLogPath sets the path of the access logs if enabled
|
||||||
// http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
|
// http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
|
||||||
// By default access logs go to /var/log/nginx/access.log
|
// By default access logs go to /var/log/nginx/access.log
|
||||||
|
@ -577,6 +582,7 @@ func NewDefault() Configuration {
|
||||||
cfg := Configuration{
|
cfg := Configuration{
|
||||||
AllowBackendServerHeader: false,
|
AllowBackendServerHeader: false,
|
||||||
AccessLogPath: "/var/log/nginx/access.log",
|
AccessLogPath: "/var/log/nginx/access.log",
|
||||||
|
AccessLogParams: "",
|
||||||
WorkerCPUAffinity: "",
|
WorkerCPUAffinity: "",
|
||||||
ErrorLogPath: "/var/log/nginx/error.log",
|
ErrorLogPath: "/var/log/nginx/error.log",
|
||||||
BlockCIDRs: defBlockEntity,
|
BlockCIDRs: defBlockEntity,
|
||||||
|
|
|
@ -59,6 +59,7 @@ func TestMergeConfigMapToStruct(t *testing.T) {
|
||||||
"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",
|
"disable-access-log": "true",
|
||||||
|
"access-log-params": "buffer=4k gzip",
|
||||||
"access-log-path": "/var/log/test/access.log",
|
"access-log-path": "/var/log/test/access.log",
|
||||||
"error-log-path": "/var/log/test/error.log",
|
"error-log-path": "/var/log/test/error.log",
|
||||||
"use-gzip": "true",
|
"use-gzip": "true",
|
||||||
|
@ -75,6 +76,7 @@ func TestMergeConfigMapToStruct(t *testing.T) {
|
||||||
def := config.NewDefault()
|
def := config.NewDefault()
|
||||||
def.CustomHTTPErrors = []int{300, 400}
|
def.CustomHTTPErrors = []int{300, 400}
|
||||||
def.DisableAccessLog = true
|
def.DisableAccessLog = true
|
||||||
|
def.AccessLogParams = "buffer=4k gzip"
|
||||||
def.AccessLogPath = "/var/log/test/access.log"
|
def.AccessLogPath = "/var/log/test/access.log"
|
||||||
def.ErrorLogPath = "/var/log/test/error.log"
|
def.ErrorLogPath = "/var/log/test/error.log"
|
||||||
def.SkipAccessLogURLs = []string{"/log", "/demo", "/test"}
|
def.SkipAccessLogURLs = []string{"/log", "/demo", "/test"}
|
||||||
|
|
|
@ -259,7 +259,7 @@ http {
|
||||||
{{ if $cfg.EnableSyslog }}
|
{{ if $cfg.EnableSyslog }}
|
||||||
access_log syslog:server={{ $cfg.SyslogHost }}:{{ $cfg.SyslogPort }} upstreaminfo if=$loggable;
|
access_log syslog:server={{ $cfg.SyslogHost }}:{{ $cfg.SyslogPort }} upstreaminfo if=$loggable;
|
||||||
{{ else }}
|
{{ else }}
|
||||||
access_log {{ $cfg.AccessLogPath }} upstreaminfo if=$loggable;
|
access_log {{ $cfg.AccessLogPath }} upstreaminfo {{ $cfg.AccessLogParams }} if=$loggable;
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
@ -751,7 +751,7 @@ stream {
|
||||||
{{ if $cfg.DisableAccessLog }}
|
{{ if $cfg.DisableAccessLog }}
|
||||||
access_log off;
|
access_log off;
|
||||||
{{ else }}
|
{{ else }}
|
||||||
access_log {{ $cfg.AccessLogPath }} log_stream;
|
access_log {{ $cfg.AccessLogPath }} log_stream {{ $cfg.AccessLogParams }};
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
error_log {{ $cfg.ErrorLogPath }};
|
error_log {{ $cfg.ErrorLogPath }};
|
||||||
|
|
Loading…
Reference in a new issue