From 7d959936d2b0da67899011a44250d33845c445b3 Mon Sep 17 00:00:00 2001 From: Alexey Pustovalov Date: Fri, 6 Dec 2024 22:10:36 +0900 Subject: [PATCH] Fixed EXPOSE_WEB_SERVER_INFO parameter for Apache on Ubuntu --- .../web-apache-mysql/ubuntu/docker-entrypoint.sh | 16 +++++++++------- .../web-apache-pgsql/ubuntu/docker-entrypoint.sh | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Dockerfiles/web-apache-mysql/ubuntu/docker-entrypoint.sh b/Dockerfiles/web-apache-mysql/ubuntu/docker-entrypoint.sh index a1a5323187..adb9a46be0 100755 --- a/Dockerfiles/web-apache-mysql/ubuntu/docker-entrypoint.sh +++ b/Dockerfiles/web-apache-mysql/ubuntu/docker-entrypoint.sh @@ -25,6 +25,8 @@ ZABBIX_ETC_DIR="/etc/zabbix" ZABBIX_WWW_ROOT="/usr/share/zabbix" # Apache main configuration file HTTPD_CONF_FILE="/etc/apache2/apache2.conf" +# Apache security configuration file +HTTPD_SECURITY_CONF_FILE="/etc/apache2/conf-enabled/security.conf" # usage: file_env VAR [DEFAULT] # as example: file_env 'MYSQL_PASSWORD' 'zabbix' @@ -234,18 +236,18 @@ prepare_zbx_web_config() { fi : ${EXPOSE_WEB_SERVER_INFO:="on"} - if [ "${EXPOSE_WEB_SERVER_INFO}" = "off" ]; then + [[ "${EXPOSE_WEB_SERVER_INFO}" != "off" ]] && EXPOSE_WEB_SERVER_INFO="on" + export EXPOSE_WEB_SERVER_INFO=${EXPOSE_WEB_SERVER_INFO} + + if [ "${EXPOSE_WEB_SERVER_INFO}" == "off" ]; then sed -i \ -e "s/^\(\s*ServerTokens\).*\$/\1 Prod/g" \ - "$HTTPD_CONF_FILE" - else - EXPOSE_WEB_SERVER_INFO="on" + "$HTTPD_SECURITY_CONF_FILE" fi - export EXPOSE_WEB_SERVER_INFO=${EXPOSE_WEB_SERVER_INFO} sed -i \ - -e "s/^\(\s*ServerSignature\).*\$/\1 ${EXPOSE_WEB_SERVER_INFO^}/g" \ - "$HTTPD_CONF_FILE" + -e "s/^\(\s*ServerSignature\).*\$/\1 ${EXPOSE_WEB_SERVER_INFO}/g" \ + "$HTTPD_SECURITY_CONF_FILE" } ################################################# diff --git a/Dockerfiles/web-apache-pgsql/ubuntu/docker-entrypoint.sh b/Dockerfiles/web-apache-pgsql/ubuntu/docker-entrypoint.sh index 04cbad2762..1941e064d4 100755 --- a/Dockerfiles/web-apache-pgsql/ubuntu/docker-entrypoint.sh +++ b/Dockerfiles/web-apache-pgsql/ubuntu/docker-entrypoint.sh @@ -25,6 +25,8 @@ ZABBIX_ETC_DIR="/etc/zabbix" ZABBIX_WWW_ROOT="/usr/share/zabbix" # Apache main configuration file HTTPD_CONF_FILE="/etc/apache2/apache2.conf" +# Apache security configuration file +HTTPD_SECURITY_CONF_FILE="/etc/apache2/conf-enabled/security.conf" # usage: file_env VAR [DEFAULT] # as example: file_env 'MYSQL_PASSWORD' 'zabbix' @@ -225,18 +227,18 @@ prepare_zbx_web_config() { fi : ${EXPOSE_WEB_SERVER_INFO:="on"} - if [ "${EXPOSE_WEB_SERVER_INFO}" = "off" ]; then + [[ "${EXPOSE_WEB_SERVER_INFO}" != "off" ]] && EXPOSE_WEB_SERVER_INFO="on" + export EXPOSE_WEB_SERVER_INFO=${EXPOSE_WEB_SERVER_INFO} + + if [ "${EXPOSE_WEB_SERVER_INFO}" == "off" ]; then sed -i \ -e "s/^\(\s*ServerTokens\).*\$/\1 Prod/g" \ - "$HTTPD_CONF_FILE" - else - EXPOSE_WEB_SERVER_INFO="on" + "$HTTPD_SECURITY_CONF_FILE" fi - export EXPOSE_WEB_SERVER_INFO=${EXPOSE_WEB_SERVER_INFO} sed -i \ - -e "s/^\(\s*ServerSignature\).*\$/\1 ${EXPOSE_WEB_SERVER_INFO^}/g" \ - "$HTTPD_CONF_FILE" + -e "s/^\(\s*ServerSignature\).*\$/\1 ${EXPOSE_WEB_SERVER_INFO}/g" \ + "$HTTPD_SECURITY_CONF_FILE" } #################################################