Skip to content

Commit 39b04c8

Browse files
committed
Added encryption support between server and frontend
1 parent dc7086e commit 39b04c8

File tree

70 files changed

+890
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+890
-243
lines changed

Dockerfiles/proxy-mysql/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ ZBX_UNREACHABLEPERIOD=45
219219
ZBX_UNAVAILABLEDELAY=60
220220
ZBX_UNREACHABLEDELAY=15
221221
ZBX_LOGSLOWQUERIES=3000
222+
ZBX_TLSLISTEN= # Available since 7.4.0
222223
ZBX_TLSCONNECT=unencrypted
223224
ZBX_TLSACCEPT=unencrypted
224225
ZBX_TLSCAFILE=

Dockerfiles/proxy-sqlite3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ ZBX_UNREACHABLEPERIOD=45
172172
ZBX_UNAVAILABLEDELAY=60
173173
ZBX_UNREACHABLEDELAY=15
174174
ZBX_LOGSLOWQUERIES=3000
175+
ZBX_TLSLISTEN= # Available since 7.4.0
175176
ZBX_TLSCONNECT=unencrypted
176177
ZBX_TLSACCEPT=unencrypted
177178
ZBX_TLSCAFILE=
@@ -196,7 +197,6 @@ ZBX_TLSCIPHERPSK13= # Available since 4.4.7
196197
ZBX_WEBDRIVERURL= # Available since 7.0.0
197198
ZBX_STARTBROWSERPOLLERS=1 # Available since 7.0.0
198199
ZBX_STARTSNMPPOLLERS=1 # Available since 7.0.0
199-
200200
```
201201

202202
Default values of these variables are specified after equal sign.

Dockerfiles/server-mysql/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ ZBX_LOGSLOWQUERIES=3000
208208
ZBX_STARTPROXYPOLLERS=1
209209
ZBX_PROXYCONFIGFREQUENCY=10
210210
ZBX_PROXYDATAFREQUENCY=1
211+
ZBX_TLSLISTEN= # Available since 7.4.0
211212
ZBX_TLSCAFILE=
212213
ZBX_TLSCA=
213214
ZBX_TLSCRLFILE=
@@ -222,6 +223,10 @@ ZBX_TLSCIPHERCERT= # Available since 4.4.7
222223
ZBX_TLSCIPHERCERT13= # Available since 4.4.7
223224
ZBX_TLSCIPHERPSK= # Available since 4.4.7
224225
ZBX_TLSCIPHERPSK13= # Available since 4.4.7
226+
ZBX_TLS_FRONTENDACCEPT= # Available since 7.4.0
227+
ZBX_FRONTENDALLOWEDIP= # Available since 7.4.0
228+
ZBX_TLSFRONTENDCERTISSUER= # Available since 7.4.0
229+
ZBX_TLSFRONTENDCERTSUBJECT= # Available since 7.4.0
225230
ZBX_WEBDRIVERURL= # Available since 7.0.0
226231
ZBX_STARTBROWSERPOLLERS=1 # Available since 7.0.0
227232
ZBX_STARTSNMPPOLLERS=1 # Available since 7.0.0

Dockerfiles/server-pgsql/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ ZBX_LOGSLOWQUERIES=3000
209209
ZBX_STARTPROXYPOLLERS=1
210210
ZBX_PROXYCONFIGFREQUENCY=10
211211
ZBX_PROXYDATAFREQUENCY=1
212+
ZBX_TLSLISTEN= # Available since 7.4.0
212213
ZBX_TLSCAFILE=
213214
ZBX_TLSCA=
214215
ZBX_TLSCRLFILE=
@@ -223,6 +224,10 @@ ZBX_TLSCIPHERCERT= # Available since 4.4.7
223224
ZBX_TLSCIPHERCERT13= # Available since 4.4.7
224225
ZBX_TLSCIPHERPSK= # Available since 4.4.7
225226
ZBX_TLSCIPHERPSK13= # Available since 4.4.7
227+
ZBX_TLS_FRONTENDACCEPT= # Available since 7.4.0
228+
ZBX_FRONTENDALLOWEDIP= # Available since 7.4.0
229+
ZBX_TLSFRONTENDCERTISSUER= # Available since 7.4.0
230+
ZBX_TLSFRONTENDCERTSUBJECT= # Available since 7.4.0
226231
ZBX_WEBDRIVERURL= # Available since 7.0.0
227232
ZBX_STARTBROWSERPOLLERS=1 # Available since 7.0.0
228233
ZBX_STARTSNMPPOLLERS=1 # Available since 7.0.0

Dockerfiles/web-apache-mysql/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@ ZBX_VAULTDBPATH= # Available since 5.2.0
241241
ZBX_VAULTURL=https://127.0.0.1:8200 # Available since 5.2.0
242242
VAULT_TOKEN= # Available since 5.2.0
243243
244+
ZBX_SERVER_TLS_ACTIVE=false # Available since 7.4.0
245+
ZBX_SERVER_TLS_CAFILE= # Available since 7.4.0
246+
ZBX_SERVER_TLS_CA= # Available since 7.4.0
247+
ZBX_SERVER_TLS_KEYFILE= # Available since 7.4.0
248+
ZBX_SERVER_TLS_KEY= # Available since 7.4.0
249+
ZBX_SERVER_TLS_CERTFILE= # Available since 7.4.0
250+
ZBX_SERVER_TLS_CERT= # Available since 7.4.0
251+
ZBX_SERVER_TLS_CERT_ISSUER= # Available since 7.4.0
252+
ZBX_SERVER_TLS_CERT_SUBJECT= # Available since 7.4.0
253+
244254
Allowed PHP-FPM configuration options:
245255
PHP_FPM_PM=dynamic
246256
PHP_FPM_PM_MAX_CHILDREN=50
@@ -262,6 +272,10 @@ Please follow official Apache2 [documentation](https://httpd.apache.org/docs/2.4
262272

263273
The volume allows to use custom certificates for SAML authentification. The volume must contains three files ``sp.key``, ``sp.crt`` and ``idp.crt``. Available since 5.0.0.
264274

275+
### ``/var/lib/zabbix/enc``
276+
277+
The volume is used to store TLS related files. These file names are specified using ``ZBX_SERVER_TLS_CAFILE``, ``ZBX_SERVER_TLS_KEYFILE`` and ``ZBX_SERVER_TLS_CERTFILE`` variables. Additionally it is possible to use environment variables ``ZBX_SERVER_TLS_CA``, ``ZBX_SERVER_TLS_KEY`` and ``ZBX_SERVER_TLS_CERT`` with plaintext values. Available since 7.4.0.
278+
265279
# The image variants
266280

267281
The `zabbix-web-apache-mysql` images come in many flavors, each designed for a specific use case.

Dockerfiles/web-apache-mysql/alpine/Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
1515
ENV TERM=xterm \
1616
ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES} \
1717
ZABBIX_CONF_DIR="/etc/zabbix" \
18+
ZABBIX_USER_HOME_DIR="/var/lib/zabbix" \
1819
ZABBIX_WWW_ROOT="/usr/share/zabbix"
1920

2021
LABEL org.opencontainers.image.authors="Alexey Pustovalov <[email protected]>" \
@@ -77,11 +78,13 @@ RUN set -eux && \
7778
--uid 1997 \
7879
--ingroup zabbix \
7980
--shell /sbin/nologin \
80-
--home /var/lib/zabbix/ \
81+
--home ${ZABBIX_USER_HOME_DIR} \
8182
zabbix && \
8283
mkdir -p ${ZABBIX_CONF_DIR} && \
8384
mkdir -p ${ZABBIX_CONF_DIR}/web && \
8485
mkdir -p ${ZABBIX_CONF_DIR}/web/certs && \
86+
mkdir -p ${ZABBIX_USER_HOME_DIR}/enc && \
87+
mkdir -p ${ZABBIX_USER_HOME_DIR}/enc_internal && \
8588
rm -f "/etc/apache2/conf.d/default.conf" && \
8689
rm -f "/etc/apache2/conf.d/ssl.conf" && \
8790
rm -f "/etc/apache2/conf.d/info.conf" && \
@@ -103,9 +106,9 @@ RUN set -eux && \
103106
chown --quiet -R zabbix:root ${ZABBIX_CONF_DIR}/ ${ZABBIX_WWW_ROOT}/include/defines.inc.php ${ZABBIX_WWW_ROOT}/modules/ && \
104107
chgrp -R 0 ${ZABBIX_CONF_DIR}/ ${ZABBIX_WWW_ROOT}/include/defines.inc.php ${ZABBIX_WWW_ROOT}/modules/ && \
105108
chmod -R g=u ${ZABBIX_CONF_DIR}/ ${ZABBIX_WWW_ROOT}/include/defines.inc.php ${ZABBIX_WWW_ROOT}/modules/ && \
106-
chown --quiet -R zabbix:root /etc/apache2/ /etc/php84/php-fpm.d/ /etc/php84/php-fpm.conf && \
107-
chgrp -R 0 /etc/apache2/ /etc/php84/php-fpm.d/ /etc/php84/php-fpm.conf && \
108-
chmod -R g=u /etc/apache2/ /etc/php84/php-fpm.d/ /etc/php84/php-fpm.conf && \
109+
chown --quiet -R zabbix:root ${ZABBIX_USER_HOME_DIR} /etc/apache2/ /etc/php84/php-fpm.d/ /etc/php84/php-fpm.conf && \
110+
chgrp -R 0 ${ZABBIX_USER_HOME_DIR} /etc/apache2/ /etc/php84/php-fpm.d/ /etc/php84/php-fpm.conf && \
111+
chmod -R g=u ${ZABBIX_USER_HOME_DIR} /etc/apache2/ /etc/php84/php-fpm.d/ /etc/php84/php-fpm.conf && \
109112
chown --quiet -R zabbix:root /var/lib/php/session/ && \
110113
chgrp -R 0 /var/lib/php/session/ && \
111114
chmod -R g=u /var/lib/php/session/

Dockerfiles/web-apache-mysql/alpine/conf/etc/zabbix/web/zabbix.conf.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,10 @@
105105
$SSO['SETTINGS'] = (json_decode($sso_settings)) ? json_decode($sso_settings, true) : array();
106106

107107
$ALLOW_HTTP_AUTH = getenv('ZBX_ALLOW_HTTP_AUTH') == 'true' ? true: false;
108+
109+
$ZBX_SERVER_TLS['ACTIVE'] = getenv('ZBX_SERVER_TLS_ACTIVE') == 'true' ? '1': '0';
110+
$ZBX_SERVER_TLS['CA_FILE'] = file_exists(getenv('ZBX_SERVER_TLS_CAFILE')) ? getenv('ZBX_SERVER_TLS_CAFILE') : '';
111+
$ZBX_SERVER_TLS['KEY_FILE'] = file_exists(getenv('ZBX_SERVER_TLS_KEYFILE')) ? getenv('ZBX_SERVER_TLS_KEYFILE') : '';
112+
$ZBX_SERVER_TLS['CERT_FILE'] = file_exists(getenv('ZBX_SERVER_TLS_CERTFILE')) ? getenv('ZBX_SERVER_TLS_CERTFILE') : '';
113+
$ZBX_SERVER_TLS['CERTIFICATE_ISSUER'] = getenv('ZBX_SERVER_TLS_CERT_ISSUER');
114+
$ZBX_SERVER_TLS['CERTIFICATE_SUBJECT'] = getenv('ZBX_SERVER_TLS_CERT_SUBJECT');

Dockerfiles/web-apache-mysql/alpine/docker-entrypoint.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ if [ "${DEBUG_MODE,,}" == "true" ]; then
99
set -o xtrace
1010
fi
1111

12+
# Internal directory for TLS related files, used when TLS*File specified as plain text values
13+
ZABBIX_INTERNAL_ENC_DIR="${ZABBIX_USER_HOME_DIR}/enc_internal"
14+
1215
# Default Zabbix installation name
1316
# Used only by Zabbix web-interface
1417
: ${ZBX_SERVER_NAME:="Zabbix docker"}
@@ -66,6 +69,22 @@ file_env() {
6669
unset "$fileVar"
6770
}
6871

72+
file_process_from_env() {
73+
local var_name=$1
74+
local file_name=$2
75+
local var_value=$3
76+
77+
if [ ! -z "$var_value" ]; then
78+
echo -n "$var_value" > "${ZABBIX_INTERNAL_ENC_DIR}/$var_name"
79+
file_name="${ZABBIX_INTERNAL_ENC_DIR}/${var_name}"
80+
fi
81+
82+
export "$var_name"="$file_name"
83+
84+
# Remove variable with plain text data
85+
unset "${var_name%%FILE}"
86+
}
87+
6988
# Check prerequisites for MySQL database
7089
check_variables() {
7190
if [ ! -n "${DB_SERVER_SOCKET}" ]; then
@@ -254,6 +273,14 @@ prepare_zbx_php_config() {
254273

255274
: ${ZBX_ALLOW_HTTP_AUTH:="true"}
256275
export ZBX_ALLOW_HTTP_AUTH=${ZBX_ALLOW_HTTP_AUTH}
276+
277+
: ${ZBX_SERVER_TLS_ACTIVE:="0"}
278+
export ZBX_SERVER_TLS_ACTIVE=${ZBX_SERVER_TLS_ACTIVE}
279+
file_process_from_env "ZBX_SERVER_TLS_CAFILE" "${ZBX_SERVER_TLS_CAFILE}" "${ZBX_SERVER_TLS_CA}"
280+
file_process_from_env "ZBX_SERVER_TLS_KEYFILE" "${ZBX_SERVER_TLS_KEYFILE}" "${ZBX_SERVER_TLS_KEY}"
281+
file_process_from_env "ZBX_SERVER_TLS_CERTFILE" "${ZBX_SERVER_TLS_CERTFILE}" "${ZBX_SERVER_TLS_CERT}"
282+
export ZBX_SERVER_TLS_CERT_ISSUER=${ZBX_SERVER_TLS_CERT_ISSUER}
283+
export ZBX_SERVER_TLS_CERT_SUBJECT=${ZBX_SERVER_TLS_CERT_SUBJECT}
257284
}
258285

259286
prepare_zbx_config() {

Dockerfiles/web-apache-mysql/centos/Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
1515
ENV TERM=xterm \
1616
ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES} \
1717
ZABBIX_CONF_DIR="/etc/zabbix" \
18+
ZABBIX_USER_HOME_DIR="/var/lib/zabbix" \
1819
ZABBIX_WWW_ROOT="/usr/share/zabbix"
1920

2021
LABEL org.opencontainers.image.authors="Alexey Pustovalov <[email protected]>" \
@@ -88,11 +89,13 @@ RUN --mount=type=tmpfs,target=/var/lib/dnf/ \
8889
-g zabbix \
8990
--uid 1997 \
9091
--shell /sbin/nologin \
91-
--home-dir /var/lib/zabbix/ \
92+
--home-dir ${ZABBIX_USER_HOME_DIR} \
9293
zabbix && \
9394
mkdir -p ${ZABBIX_CONF_DIR} && \
9495
mkdir -p ${ZABBIX_CONF_DIR}/web && \
9596
mkdir -p ${ZABBIX_CONF_DIR}/web/certs && \
97+
mkdir -p ${ZABBIX_USER_HOME_DIR}/enc && \
98+
mkdir -p ${ZABBIX_USER_HOME_DIR}/enc_internal && \
9699
rm -f "/etc/httpd/conf.d/default.conf" && \
97100
rm -f "/etc/httpd/conf.d/ssl.conf" && \
98101
rm -f "/etc/httpd/conf.d/autoindex.conf" && \
@@ -115,9 +118,9 @@ RUN --mount=type=tmpfs,target=/var/lib/dnf/ \
115118
chown --quiet -R zabbix:root ${ZABBIX_CONF_DIR}/ ${ZABBIX_WWW_ROOT}/include/defines.inc.php ${ZABBIX_WWW_ROOT}/modules/ && \
116119
chgrp -R 0 ${ZABBIX_CONF_DIR}/ ${ZABBIX_WWW_ROOT}/include/defines.inc.php ${ZABBIX_WWW_ROOT}/modules/ && \
117120
chmod -R g=u ${ZABBIX_CONF_DIR}/ ${ZABBIX_WWW_ROOT}/include/defines.inc.php ${ZABBIX_WWW_ROOT}/modules/ && \
118-
chown --quiet -R zabbix:root /etc/httpd/ /etc/php-fpm.d/ /etc/php-fpm.conf && \
119-
chgrp -R 0 /etc/httpd/ /etc/php-fpm.d/ /etc/php-fpm.conf && \
120-
chmod -R g=u /etc/httpd/ /etc/php-fpm.d/ /etc/php-fpm.conf && \
121+
chown --quiet -R zabbix:root ${ZABBIX_USER_HOME_DIR}/ /etc/httpd/ /etc/php-fpm.d/ /etc/php-fpm.conf && \
122+
chgrp -R 0 ${ZABBIX_USER_HOME_DIR}/ /etc/httpd/ /etc/php-fpm.d/ /etc/php-fpm.conf && \
123+
chmod -R g=u ${ZABBIX_USER_HOME_DIR}/ /etc/httpd/ /etc/php-fpm.d/ /etc/php-fpm.conf && \
121124
chown --quiet -R zabbix:root /run/httpd/ /var/lib/php/session/ && \
122125
chgrp -R 0 /run/httpd/ /var/lib/php/session/ && \
123126
chmod -R g=u /run/httpd/ /var/lib/php/session/ && \

Dockerfiles/web-apache-mysql/centos/conf/etc/zabbix/web/zabbix.conf.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,10 @@
105105
$SSO['SETTINGS'] = (json_decode($sso_settings)) ? json_decode($sso_settings, true) : array();
106106

107107
$ALLOW_HTTP_AUTH = getenv('ZBX_ALLOW_HTTP_AUTH') == 'true' ? true: false;
108+
109+
$ZBX_SERVER_TLS['ACTIVE'] = getenv('ZBX_SERVER_TLS_ACTIVE') == 'true' ? '1': '0';
110+
$ZBX_SERVER_TLS['CA_FILE'] = file_exists(getenv('ZBX_SERVER_TLS_CAFILE')) ? getenv('ZBX_SERVER_TLS_CAFILE') : '';
111+
$ZBX_SERVER_TLS['KEY_FILE'] = file_exists(getenv('ZBX_SERVER_TLS_KEYFILE')) ? getenv('ZBX_SERVER_TLS_KEYFILE') : '';
112+
$ZBX_SERVER_TLS['CERT_FILE'] = file_exists(getenv('ZBX_SERVER_TLS_CERTFILE')) ? getenv('ZBX_SERVER_TLS_CERTFILE') : '';
113+
$ZBX_SERVER_TLS['CERTIFICATE_ISSUER'] = getenv('ZBX_SERVER_TLS_CERT_ISSUER');
114+
$ZBX_SERVER_TLS['CERTIFICATE_SUBJECT'] = getenv('ZBX_SERVER_TLS_CERT_SUBJECT');

0 commit comments

Comments
 (0)