diff --git a/internal/ingress/controller/config/config.go b/internal/ingress/controller/config/config.go index 386753d06d..f5615a9cb0 100644 --- a/internal/ingress/controller/config/config.go +++ b/internal/ingress/controller/config/config.go @@ -475,6 +475,13 @@ type Configuration struct { // http://nginx.org/en/docs/http/ngx_http_limit_req_module.html#limit_req_status // Default: 503 LimitReqStatusCode int `json:"limit-req-status-code"` + + // EnableSyslog enables the configuration for remote logging in NGINX + EnableSyslog bool `json:"enable-syslog"` + // SyslogHost FQDN or IP address where the logs should be sent + SyslogHost string `json:"syslog-host"` + // SyslogPort port + SyslogPort int `json:"syslog-port",omitempty` } // NewDefault returns the default nginx configuration @@ -569,6 +576,7 @@ func NewDefault() Configuration { JaegerSamplerType: "const", JaegerSamplerParam: "1", LimitReqStatusCode: 503, + SyslogPort: 514, } if glog.V(5) { diff --git a/rootfs/etc/nginx/template/nginx.tmpl b/rootfs/etc/nginx/template/nginx.tmpl index b724b4aa6b..4c29eba500 100644 --- a/rootfs/etc/nginx/template/nginx.tmpl +++ b/rootfs/etc/nginx/template/nginx.tmpl @@ -150,9 +150,18 @@ http { {{ if $cfg.DisableAccessLog }} access_log off; {{ else }} + {{ if $cfg.EnableSyslog }} + access_log syslog:server={{ $cfg.SyslogHost }}:{{ $cfg.SyslogPort }} upstreaminfo if=$loggable; + {{ else }} access_log {{ $cfg.AccessLogPath }} upstreaminfo if=$loggable; {{ end }} + {{ end }} + + {{ if $cfg.EnableSyslog }} + error_log syslog:server={{ $cfg.SyslogHost }}:{{ $cfg.SyslogPort }} {{ $cfg.ErrorLogLevel }}; + {{ else }} error_log {{ $cfg.ErrorLogPath }} {{ $cfg.ErrorLogLevel }}; + {{ end }} {{ buildResolvers $cfg.Resolver $cfg.DisableIpv6DNS }}