Zabbixをhttpsでアクセスできるようにする

Zabbixにhttpsでアクセスできるようにしてみます。
証明書は自己証明書で。

今回はOpenSSLとapacheのmod_sslで実現してみました。

OpenSSLを導入

導入されているか確認

# rpm -qa | grep openssl
openssl-1.0.0a-4.1.7.amzn1.x86_64
openssl-devel-1.0.0a-4.1.7.amzn1.x86_64

確認して、opensslとopenssl-develがインストールされていればOK。
インストールされていない場合は2つのパッケージをインストール。

apacheにmod_sslを組み込む

mod_sslが組み込まれているか確認

# httpd -l
Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c

入っていない。
通常、インストール時に--enable-sslを指定してインストールすればインストールされるが、
すでにapacheのインストールが終わっていて後から導入する場合は下記手順を実施する。

yumでmod_sslパッケージをインストール

今回はCentOSサーバなのでyumで簡単に実施します。

# yum install mod_ssl
RSA秘密鍵作成
# openssl genrsa -des3 -out server.key.secure 2048
# openssl rsa -in server.key.secure -out server.key
# chmod 400 server.key
署名要求作成
# openssl req -new -key server.key -out server.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
        • -
Country Name (2 letter code) [XX]:JP State or Province Name (full name) :Tokyo Locality Name (eg, city) [Default City]:xxxku Organization Name (eg, company) [Default Company Ltd]:ike-dai.com Organizational Unit Name (eg, section) : Common Name (eg, your name or your server's hostname) :ike-dai.com Email Address :xxxxx@gmail.com Please enter the following 'extra' attributes to be sent with your certificate request A challenge password : An optional company name : # chmod 400 server.csr
CA証明書作成
# openssl x509 -in server.csr -out server.pem -req -signkey server.key -days 365
apacheの設定ファイル変更

ssl.confの設定を変更してssl設定を追加していきます。
yumapache,mod_sslをインストールしていれば下記のファイルを編集するだけでOK。
/etc/httpd/conf.d/ssl.conf



DocumentRoot "/var/www/html"

SSLCertificateFile /path/server.pem
SSLCertificateKeyFile /path/server.key

・・・略

httpsでアクセスした時のDocumentRootの指定、秘密鍵の場所指定、証明書の場所指定を設定するだけでOKです。
但し、zabbixをソースからインストールしている等zabbixの配置場所が異なっていたりする場合は環境に応じて変更してください。

これであとはhttps://xxx.xxx.xxx.xxx/zabbixにアクセスすればOKです。
iptablesとかでフィルタリングしている人は開放してあげてください。