From 11e8235ba2de6a6c858737c91c61a7520f1e548b Mon Sep 17 00:00:00 2001 From: RadeJR <33696623+RadeJR@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:19:54 +0200 Subject: [PATCH] Disable FPM Access Log by default (#374) * Add an option to disable/redirect fpm access logs * forgot to add removing line in commit * Disabled access log and moved access log to Debug Mode only * Removed healthcheck from Apache access logs --------- Co-authored-by: Ilija Radojkovic Co-authored-by: Jay Rogers --- src/common/etc/entrypoint.d/1-debug-mode.sh | 3 +++ .../etc/php-fpm.d/docker-php-serversideup-pool.conf | 2 +- .../fpm-apache/etc/apache2/vhost-templates/http.conf | 9 +++++++-- .../fpm-apache/etc/apache2/vhost-templates/https.conf | 9 +++++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/common/etc/entrypoint.d/1-debug-mode.sh b/src/common/etc/entrypoint.d/1-debug-mode.sh index a6c3d75b..05d1474a 100644 --- a/src/common/etc/entrypoint.d/1-debug-mode.sh +++ b/src/common/etc/entrypoint.d/1-debug-mode.sh @@ -44,6 +44,9 @@ set_fpm_log_level (){ fpm_log_level=$1 sed -i "/\[global\]/a log_level = $fpm_log_level" /usr/local/etc/php-fpm.conf echo "ℹ️ NOTICE ($script_name): FPM - log_level has been set to \"$fpm_log_level\"" + + echo "access.log = /proc/self/fd/2" >> /usr/local/etc/php-fpm.d/zzz-docker-php-serversideup-fpm-debug.conf + echo "ℹ️ NOTICE ($script_name): FPM - access.log has been set to \"STDERR\"" } ####################################### diff --git a/src/php-fpm.d/usr/local/etc/php-fpm.d/docker-php-serversideup-pool.conf b/src/php-fpm.d/usr/local/etc/php-fpm.d/docker-php-serversideup-pool.conf index 35018896..f4ce929d 100644 --- a/src/php-fpm.d/usr/local/etc/php-fpm.d/docker-php-serversideup-pool.conf +++ b/src/php-fpm.d/usr/local/etc/php-fpm.d/docker-php-serversideup-pool.conf @@ -55,7 +55,7 @@ listen = 9000 ; php-fpm closes STDOUT on startup, so sending logs to /proc/self/fd/1 does not work. ; https://bugs.php.net/bug.php?id=73886 -access.log = /proc/self/fd/2 +; access.log = /proc/self/fd/2 ; Redirect worker stdout and stderr into main error log. If not set, stdout and ; stderr will be redirected to /dev/null according to FastCGI specs. diff --git a/src/variations/fpm-apache/etc/apache2/vhost-templates/http.conf b/src/variations/fpm-apache/etc/apache2/vhost-templates/http.conf index 4c1ae921..56101aa7 100644 --- a/src/variations/fpm-apache/etc/apache2/vhost-templates/http.conf +++ b/src/variations/fpm-apache/etc/apache2/vhost-templates/http.conf @@ -30,10 +30,15 @@ ProxyPassReverse "/healthcheck" "fcgi://localhost:9000" # Set the Proxy Timeout to be 30 minutes ProxyTimeout 1800 -# Configure Log Settings +# Set environment variable for healthcheck requests +SetEnvIf Request_URI "^/healthcheck$" dontlog + +# CustomLog directive to conditionally log requests LogFormat "%l %u %t %v %a \"%r\" %>s %b" comonvhost +CustomLog /dev/stdout comonvhost env=!dontlog + +# Configure Log Settings ErrorLog /dev/stderr -TransferLog /dev/stdout LogLevel ${LOG_OUTPUT_LEVEL} # Disable Server Signature for increased security diff --git a/src/variations/fpm-apache/etc/apache2/vhost-templates/https.conf b/src/variations/fpm-apache/etc/apache2/vhost-templates/https.conf index 8952a002..79277b6b 100644 --- a/src/variations/fpm-apache/etc/apache2/vhost-templates/https.conf +++ b/src/variations/fpm-apache/etc/apache2/vhost-templates/https.conf @@ -35,10 +35,15 @@ ProxyPassReverse "/healthcheck" "fcgi://localhost:9000" # Set the Proxy Timeout to be 30 minutes ProxyTimeout 1800 -# Configure Log Settings +# Set environment variable for healthcheck requests +SetEnvIf Request_URI "^/healthcheck$" dontlog + +# CustomLog directive to conditionally log requests LogFormat "%l %u %t %v %a \"%r\" %>s %b" comonvhost +CustomLog /dev/stdout comonvhost env=!dontlog + +# Configure Log Settings ErrorLog /dev/stderr -TransferLog /dev/stdout LogLevel ${LOG_OUTPUT_LEVEL} # Disable Server Signature for increased security