Webインターフェースへの安全な接続

概要

このセクションでは、Zabbix Webインターフェースと Zabbix サーバー間の安全な TLS 接続のための Zabbix のセットアップ手順と設定例を説明します。

設定

デフォルトでは、Zabbix WebインターフェースとZabbixサーバー間の通信は暗号化されません。セキュリティを強化するには、両方でTLSを有効にします。以下に、これを行う最も簡単な方法の例を示します。

1. 証明書とキーを生成します。

作業ディレクトリを作成します。

sudo mkdir -p /etc/zabbix/ssl && cd /etc/zabbix/ssl

CA証明書を作成します(MyZabbixCA の値は実際のコモンネームに合わせて変更してください)。

sudo openssl genrsa -out ca.key 4096
sudo openssl req -new -x509 -days 3650 -key ca.key -out ca.crt -subj "/CN=MyZabbixCA/"

Zabbixサーバー用の秘密鍵と証明書を生成します(zabbix-server.example.com の値は実際のコモンネームに合わせて変更してください)。

sudo openssl genrsa -out server.key 2048
sudo openssl req -new -key server.key -out server.csr -subj "/CN=zabbix-server.example.com/"
sudo openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -sha256 -out server.crt

Zabbix Webインターフェース用の秘密鍵と証明書を生成します(zabbix-frontend-node の値は実際のコモンネームに合わせて変更してください)。

sudo openssl genrsa -out frontend.key 2048
sudo openssl req -new -key frontend.key -out frontend.csr -subj "/CN=zabbix-frontend-node/"
sudo openssl x509 -req -days 365 -in frontend.csr -CA ca.crt -CAkey ca.key -CAcreateserial -sha256 -out frontend.crt

2. 適切な権限を設定します。

Zabbixサーバーの場合(所有者とグループは、使用しているディストリビューションのZabbixサーバーデーモンユーザーに合わせて変更してください)。

sudo chown root:zabbix /etc/zabbix/ssl/server.{crt,key} /etc/zabbix/ssl/ca.crt
sudo chmod 640 /etc/zabbix/ssl/server.key
sudo chmod 644 /etc/zabbix/ssl/server.crt /etc/zabbix/ssl/ca.crt

Webインターフェースの場合(所有者とグループは、使用しているディストリビューションのWebサーバーユーザーに合わせて変更してください)。

sudo chown root:www-data /etc/zabbix/ssl/frontend.{crt,key}
sudo chmod 640 /etc/zabbix/ssl/frontend.key
sudo chmod 644 /etc/zabbix/ssl/frontend.crt

3. Zabbixサーバーを設定します。

サーバー設定ファイルzabbix_server.conf)に次の設定を追加します。

TLSFrontendAccept=cert
TLSCertFile=/etc/zabbix/ssl/server.crt
TLSKeyFile=/etc/zabbix/ssl/server.key
TLSCAFile=/etc/zabbix/ssl/ca.crt
# オプション:
# TLSFrontendCertIssuer=CN=MyZabbixCA
# TLSFrontendCertSubject=CN=zabbix-frontend-node

次に、サーバーを再起動します。

sudo systemctl restart zabbix-server

4. Zabbix Webインターフェースを設定します。

Webインターフェースのインストール中に、Webインターフェースからの接続を暗号化 オプションを有効にします(必要に応じて、サーバー証明書の発行者とサブジェクトを検証 オプションも有効にします)。次に、TLS CAファイルTLSキーファイルTLS証明書ファイル の各フィールド(必要に応じて、サーバーTLS証明書の発行者 および サーバーTLS証明書のサブジェクト フィールドも)に値を入力します。

パラメーター 説明
TLS CAファイル サーバーの証明書の検証に使用する認証局(CA)証明書ファイルの完全なパスを指定します。
TLSキーファイル クライアント証明書に対応するクライアント秘密鍵ファイルの完全なパスを指定します。
TLS証明書ファイル 相互TLS認証が必要な場合は、クライアント証明書ファイルの完全なパスを指定します。
サーバーTLS証明書の発行者 サーバーの証明書と照合する発行者の識別名(DN)を指定します。
サーバーTLS証明書のサブジェクト サーバーの証明書と照合するサブジェクトの識別名(DN)を指定します。

既存のインストール環境では、Webインターフェース設定ファイルで次のパラメーターを編集します。

$ZBX_SERVER_TLS['ACTIVE'] = 'true';
$ZBX_SERVER_TLS['CA_FILE'] = '/etc/zabbix/ssl/ca.crt';
$ZBX_SERVER_TLS['KEY_FILE'] = '/etc/zabbix/ssl/frontend.key';
$ZBX_SERVER_TLS['CERT_FILE'] = '/etc/zabbix/ssl/frontend.crt';
// オプション:
// $ZBX_SERVER_TLS['CERTIFICATE_ISSUER']  = 'CN=MyZabbixCA';
// $ZBX_SERVER_TLS['CERTIFICATE_SUBJECT'] = 'CN=zabbix-server.example.com';

5. Zabbix WebインターフェースまたはZabbixサーバーのログファイルにエラーメッセージがないことを確認して、暗号化を検証します。

tail -f /var/log/zabbix/zabbix_server.log

Troubleshooting

Incorrect or incomplete TLS configuration can cause errors in the Zabbix frontend or indicate that the Zabbix server is running but the connection is not established successfully:

To identify the exact configuration issue, set the Zabbix server log level to 4, reproduce the error in the frontend, and check the Zabbix server log for the corresponding error message.

The following cases describe common errors and their possible causes.

Frontend IP address is not allowed

The Zabbix server log contains an error similar to:

54283:20260819:105926.400 frontend connection from "127.0.0.1" is not allowed by FrontendAllowedIP

The connection is dropped after the TCP handshake because the frontend IP address is not authorized.

Add the frontend IP address to the FrontendAllowedIP parameter in zabbix_server.conf and restart the Zabbix server.

Unencrypted connection is not allowed

The Zabbix server log contains an error similar to:

56884:20260819:111154.285 frontend connection of type "unencrypted" is not allowed by TLSFrontendAccept

The Zabbix server is configured to accept only TLS connections, for example with TLSFrontendAccept=cert, but the frontend is attempting to connect without encryption.

Enable frontend encryption and configure the required TLS files in zabbix.conf.php, as described in step 4 of the Configuration.

Frontend attempts TLS while server expects unencrypted

The Zabbix server log contains an error similar to:

61091:20260819:115916.019 End of zbx_tls_accept():FAIL error:'TLS handshake set result code to 1: file ../ssl/record/rec_layer_s3.c line 317 func ssl3_read_n: error:0A000126:SSL routines::unexpected eof while reading: TLS write fatal alert "decode error"'

The exact error message depends on the OpenSSL version.

The Zabbix server is configured to accept only unencrypted connections, for example with TLSFrontendAccept=unencrypted, while the frontend is attempting to establish a TLS connection.

Configure the Zabbix server to accept TLS connections by setting TLSFrontendAccept=cert and defining TLSCertFile and TLSKeyFile in zabbix_server.conf. Alternatively, disable frontend encryption in zabbix.conf.php.

Frontend certificate is not trusted

The Zabbix server log contains an error similar to:

62248:20260819:124203.812 End of zbx_tls_accept():FAIL error:'self-signed certificate: TLS handshake set result code to 1: file ../ssl/statem/statem_srvr.c line 3522 func tls_process_client_certificate: error:0A000086:SSL routines::certificate verify failed: TLS write fatal alert "unknown CA"'

The frontend presented a certificate, but the Zabbix server does not trust the Certificate Authority (CA) that signed it.

The same problem can also appear in the frontend system information as:

fread(): SSL operation failed with code 1. OpenSSL Error messages:

error:0A000418:SSL routines::tlsv1 alert unknown ca [zabbix.php:17 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → Widgets\SystemInfo\Actions\WidgetView->doAction() → CSystemInfoHelper::getData() → CSystemInfoHelper::getServerStatus() → CZabbixServer->getStatus() → CZabbixServer->request() → fread() → CConfigFile->{closure:/user/share/conf/zabbix.conf.php:89}() in conf/zabbix.conf.php:95]

The frontend may also display "Incorrect response received from Zabbix server "localhost"".

Verify that the frontend certificate is signed by the CA specified by TLSCAFile in zabbix_server.conf.

TLS key file is not readable

The frontend may display "TLS key file: file is not readable."

It may also display "Unable to connect to the Zabbix server due to TLS settings. Some functions are unavailable.".

The web server user does not have sufficient permissions to read one or more certificate, key, or CA files configured in zabbix.conf.php. This can occur when certificate files are stored in a restricted directory, such as /root/ or a user's home directory.

Move the certificate files to a directory accessible to the web server and set appropriate permissions as described in step 2 of the Configuration.

TLS files are invalid or corrupted

The frontend may display "Unable to connect to the Zabbix server due to TLS settings. Some functions are unavailable.".

This can occur when the configured certificate or key files exist and are readable, but their contents are empty, corrupted, or otherwise invalid. In this case, the frontend does not establish a connection to the Zabbix server, and no corresponding connection attempt appears in the Zabbix server log.

Verify that the certificate and key files contain valid, properly formatted data and that the private key corresponds to the certificate.