Просмотр исходного кода

Add Docker access log toggle (#9191)

* Add Docker access log toggle

Allow container operators to disable Apache access logging with DISABLE_ACCESS_LOG=1 while preserving the existing default.

* Use positive access log toggle

* Include dev container

* Better POSIX compatibility
```
  -E, -r, --regexp-extended
                 use extended regular expressions in the script
                 (for portability use POSIX -E).
```

Note: we should probably replace the other `sed -r` by `sed -E` elsewhere

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Morax 3 недель назад
Родитель
Сommit
4023406fee

+ 1 - 0
.devcontainer/Dockerfile

@@ -30,6 +30,7 @@ ENV COPY_LOG_TO_SYSLOG=On
 ENV COPY_SYSLOG_TO_STDERR=On
 ENV CRON_MIN=''
 ENV DATA_PATH=''
+ENV ENABLE_ACCESS_LOG=1
 ENV FRESHRSS_ENV='development'
 ENV LISTEN='0.0.0.0:8080'
 ENV TRUSTED_PROXY=0

+ 1 - 0
Docker/Dockerfile

@@ -59,6 +59,7 @@ ENV COPY_LOG_TO_SYSLOG=On
 ENV COPY_SYSLOG_TO_STDERR=On
 ENV CRON_MIN=''
 ENV DATA_PATH=''
+ENV ENABLE_ACCESS_LOG=1
 ENV FRESHRSS_ENV=''
 ENV LISTEN=''
 ENV OIDC_ENABLED=''

+ 1 - 0
Docker/Dockerfile-Alpine

@@ -55,6 +55,7 @@ ENV COPY_LOG_TO_SYSLOG=On
 ENV COPY_SYSLOG_TO_STDERR=On
 ENV CRON_MIN=''
 ENV DATA_PATH=''
+ENV ENABLE_ACCESS_LOG=1
 ENV FRESHRSS_ENV=''
 ENV LISTEN=''
 ENV OIDC_ENABLED=''

+ 1 - 0
Docker/Dockerfile-Arch

@@ -56,6 +56,7 @@ ENV COPY_LOG_TO_SYSLOG=On
 ENV COPY_SYSLOG_TO_STDERR=On
 ENV CRON_MIN=''
 ENV DATA_PATH=''
+ENV ENABLE_ACCESS_LOG=1
 ENV FRESHRSS_ENV=''
 ENV LISTEN=''
 ENV OIDC_ENABLED=''

+ 1 - 0
Docker/Dockerfile-Newest

@@ -59,6 +59,7 @@ ENV COPY_LOG_TO_SYSLOG=On
 ENV COPY_SYSLOG_TO_STDERR=On
 ENV CRON_MIN=''
 ENV DATA_PATH=''
+ENV ENABLE_ACCESS_LOG=1
 ENV FRESHRSS_ENV=''
 ENV LISTEN=''
 ENV OIDC_ENABLED=''

+ 1 - 0
Docker/Dockerfile-Oldest

@@ -57,6 +57,7 @@ ENV COPY_LOG_TO_SYSLOG=On
 ENV COPY_SYSLOG_TO_STDERR=On
 ENV CRON_MIN=''
 ENV DATA_PATH=''
+ENV ENABLE_ACCESS_LOG=1
 ENV FRESHRSS_ENV=''
 ENV LISTEN=''
 ENV OIDC_ENABLED=''

+ 1 - 0
Docker/README.md

@@ -94,6 +94,7 @@ and with newer packages in general (Apache, PHP).
 * `TZ`: (default is `UTC`) A [server timezone](http://php.net/timezones)
 * `CRON_MIN`: (default is disabled) Define minutes for the built-in cron job to automatically refresh feeds (see below for more advanced options)
 * `DATA_PATH`: (default is empty, defined by `./constants.local.php` or `./constants.php`) Defines the path for writeable data.
+* `ENABLE_ACCESS_LOG`: (default is `1`) Set to `0` to disable the Apache access log.
 * `FRESHRSS_ENV`: (default is `production`) Enables additional development information if set to `development` (increases the level of logging and ensures that errors are displayed) (see below for more development options)
 * `COPY_LOG_TO_SYSLOG`: (default is `On`) Copy all the logs to syslog
 * `COPY_SYSLOG_TO_STDERR`: (default is `On`) Copy syslog to Standard Error so that it is visible in docker logs

+ 4 - 0
Docker/entrypoint.sh

@@ -24,6 +24,10 @@ if [ -z "$APACHE_CONFIG" ]; then
 	exit 11
 fi
 
+if [ "$ENABLE_ACCESS_LOG" = "0" ]; then
+	sed -E -i '/^[ \t]*CustomLog[ \t]/s/^/#/' "$APACHE_CONFIG"
+fi
+
 if [ -n "$LISTEN" ]; then
 	sed -r -i "\\#^Listen#s#^.*#Listen $LISTEN#" "$APACHE_CONFIG"
 fi