From 7bdf9c5e52c55bb38845dc4da3f80dd7d502d40f Mon Sep 17 00:00:00 2001 From: Phillip Wirth Date: Fri, 24 Jan 2025 15:17:46 +0100 Subject: [PATCH 1/2] optionally enable json log --- Dockerfile | 1 + config/docker/nginx.conf.template | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/Dockerfile b/Dockerfile index 8ab1b7d736..d3a58eddd3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,7 @@ RUN if [ -f "public/themes/${SC_THEME}/bbb/presentation.pdf" ]; then \ # run stage FROM docker.io/nginx:1.27 +ENV LOG_FORMAT main RUN mkdir /etc/nginx/templates COPY config/docker/nginx.conf.template /etc/nginx/templates/default.conf.template COPY --from=build-stage /app/dist /usr/share/nginx/html/frontend diff --git a/config/docker/nginx.conf.template b/config/docker/nginx.conf.template index 4f6994f11a..8dc836eb0d 100644 --- a/config/docker/nginx.conf.template +++ b/config/docker/nginx.conf.template @@ -1,4 +1,19 @@ +# Conditionally enable json log +log_format json escape=json + '{' + '"time_local":"$time_local",' + '"remote_addr":"$remote_addr",' + '"remote_user":"$remote_user",' + '"request":"$request",' + '"status": "$status",' + '"body_bytes_sent":"$body_bytes_sent",' + '"request_time":"$request_time",' + '"http_referrer":"$http_referer",' + '"http_user_agent":"$http_user_agent"' + '}'; + server { + access_log /var/log/nginx/access.log ${LOG_FORMAT}; listen 4000; server_name localhost; From 942040199c904a7bee240cba1ab9265e7db54168 Mon Sep 17 00:00:00 2001 From: Phillip Wirth Date: Fri, 24 Jan 2025 15:33:06 +0100 Subject: [PATCH 2/2] rename LOG_FORMAT to NGINX_LOG_FORMAT --- Dockerfile | 2 +- config/docker/nginx.conf.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d3a58eddd3..884015a338 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ RUN if [ -f "public/themes/${SC_THEME}/bbb/presentation.pdf" ]; then \ # run stage FROM docker.io/nginx:1.27 -ENV LOG_FORMAT main +ENV NGINX_LOG_FORMAT main RUN mkdir /etc/nginx/templates COPY config/docker/nginx.conf.template /etc/nginx/templates/default.conf.template COPY --from=build-stage /app/dist /usr/share/nginx/html/frontend diff --git a/config/docker/nginx.conf.template b/config/docker/nginx.conf.template index 8dc836eb0d..ce8c2a769a 100644 --- a/config/docker/nginx.conf.template +++ b/config/docker/nginx.conf.template @@ -13,7 +13,7 @@ log_format json escape=json '}'; server { - access_log /var/log/nginx/access.log ${LOG_FORMAT}; + access_log /var/log/nginx/access.log ${NGINX_LOG_FORMAT}; listen 4000; server_name localhost;