From 2112c306a8dc7ea0cd79d0f8587db095bd955438 Mon Sep 17 00:00:00 2001 From: bunkerity Date: Wed, 2 Dec 2020 16:46:54 +0100 Subject: [PATCH] custom log format --- confs/global/nginx.conf | 3 ++- entrypoint/defaults.sh | 1 + entrypoint/global-config.sh | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/confs/global/nginx.conf b/confs/global/nginx.conf index a49761f..6033f82 100644 --- a/confs/global/nginx.conf +++ b/confs/global/nginx.conf @@ -48,7 +48,8 @@ http { default_type application/octet-stream; # write logs to local syslog - access_log syslog:server=unix:/dev/log,nohostname,facility=local0,severity=notice combined; + log_format logf '%LOG_FORMAT%'; + access_log syslog:server=unix:/dev/log,nohostname,facility=local0,severity=notice logf; error_log syslog:server=unix:/dev/log,nohostname,facility=local0 warn; # temp paths diff --git a/entrypoint/defaults.sh b/entrypoint/defaults.sh index dd0fc12..328390f 100644 --- a/entrypoint/defaults.sh +++ b/entrypoint/defaults.sh @@ -1,6 +1,7 @@ #!/bin/bash MULTISITE="${MULTISITE-no}" +LOG_FORMAT="${LOG_FORMAT-\$remote_addr - \$remote_user \$host [\$time_local] \"$request\" \$status \$body_bytes_sent \"\$http_referer\" \"\$http_user_agent\"}" HTTP_PORT="${HTTP_PORT-8080}" HTTPS_PORT="${HTTPS_PORT-8443}" MAX_CLIENT_SIZE="${MAX_CLIENT_SIZE-10m}" diff --git a/entrypoint/global-config.sh b/entrypoint/global-config.sh index 64a6cc7..7eb3106 100644 --- a/entrypoint/global-config.sh +++ b/entrypoint/global-config.sh @@ -31,6 +31,9 @@ else replace_in_file "/etc/nginx/nginx.conf" "%INCLUDE_SERVER%" "include /etc/nginx/server.conf;" fi +# custom log format +replace_in_file "/etc/nginx/nginx.conf" "%LOG_FORMAT%" "$LOG_FORMAT" + # proxy_cache zone if [ "$(has_value USE_PROXY_CACHE yes)" != "" ] ; then replace_in_file "/etc/nginx/nginx.conf" "%PROXY_CACHE_PATH%" "proxy_cache_path /tmp/proxy_cache keys_zone=proxycache:${PROXY_CACHE_PATH_ZONE_SIZE} ${PROXY_CACHE_PATH_PARAMS};"