Fixed EXPOSE_WEB_SERVER_INFO parameter for Apache on Ubuntu

This commit is contained in:
Alexey Pustovalov 2024-12-06 22:10:36 +09:00
parent 1fd73dce18
commit da22cf7a78
2 changed files with 18 additions and 14 deletions

View File

@ -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'
@ -240,18 +242,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"
}
#################################################

View File

@ -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'
@ -231,18 +233,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"
}
#################################################