diff --git a/extenginx/Containerfile b/extenginx/Containerfile index 8de7f1be..6f87d8fb 100644 --- a/extenginx/Containerfile +++ b/extenginx/Containerfile @@ -21,6 +21,7 @@ FROM alpine:3.19 AS nginx-runtime-0 RUN apk update && apk upgrade && apk add \ nginx \ nginx-mod-mail \ + nginx-mod-stream \ ; diff --git a/extenginx/include.d/stream/README.md b/extenginx/include.d/stream/README.md new file mode 100644 index 00000000..dce8ae3d --- /dev/null +++ b/extenginx/include.d/stream/README.md @@ -0,0 +1,4 @@ +# stream block snippets + +files with `.conf` extension in this directory will be included in the stream block after +the default events options. diff --git a/extenginx/nginx.conf.template b/extenginx/nginx.conf.template index 25066245..e9edba41 100644 --- a/extenginx/nginx.conf.template +++ b/extenginx/nginx.conf.template @@ -8,11 +8,12 @@ worker_processes auto; # Enables the use of JIT for regular expressions to speed-up their processing. pcre_jit on; -# Configures default error logger. -error_log /var/log/nginx/error.log warn; +# Sends error message (of at least warn level) to stderr. +error_log stderr warn; # Load dynamic modules. load_module "modules/ngx_mail_module.so"; +load_module "modules/ngx_stream_module.so"; # Include files with config snippets into the root context. @@ -83,8 +84,8 @@ http { '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; - # Sets the path, format, and configuration for a buffered log write. - access_log /var/log/nginx/access.log main; + # Send logs to stdout using main log format. + access_log /proc/self/fd/1 main; include /etc/nginx/include.d/http/*.conf; @@ -169,3 +170,16 @@ mail { include /etc/nginx/include.d/server_pop3s/*.conf; } } + +stream { + # Specifies the main log format. + log_format main '$remote_addr [$time_local] ' + '$protocol $status $bytes_sent $bytes_received ' + '$session_time "$upstream_addr" ' + '"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"'; + + # Send logs to stdout using main log format. + access_log /proc/self/fd/1 main; + + include /etc/nginx/include.d/stream/*.conf; +}