diff --git a/Dockerfile b/Dockerfile index 8ab1b7d736..884015a338 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 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 4f6994f11a..ce8c2a769a 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 ${NGINX_LOG_FORMAT}; listen 4000; server_name localhost;