Zabbix 2.4.6 on Centos 7.1 – Part 3

We start of installing stunnel and prerequisites on the zabbix server (and not proxy)

Yum -y install stunnel gcc openssl-devel

When we first install stunnel, we have to make our certificates that we then can use to encrypt our zabbix traffic.

To make the keys (note the -days on the openssl)

mkdir /etc/stunnel
cd /etc/stunnel
openssl req -new -x509 -nodes -out cert.pem -keyout cert.key -days 1095

So we got the keys, next we need to copy it to our proxies:
root@192.168.220.132 (where root is your username and ip adress of the proxy server, preferable you should use another username then root)

scp /etc/stunnel/cert.key <a class="external-link" href="mailto:root@192.168.220.132" rel="nofollow">root@192.168.224.132</a>:/etc/stunnel
scp /etc/stunnel/cert.pem <a class="external-link" href="mailto:root@192.168.220.132" rel="nofollow">root@192.168.224.132</a>:/etc/stunnel

Stunnel Config files:

Nextup we use are going to config the stunnel config file. We will make a new one and name it:

sudo nano /etc/stunnel/stunnel.conf

In the config file, add the following lines:

cert = /etc/stunnel/cert.pem
key = /etc/stunnel/cert.key


[ZAB]

accept=11612
connect=10051

For the proxy, where xxx.xxx.xxx.xxx is the ip adres of your zabbix server:
/etc/stunnel/stunnel.conf

cert = /etc/stunnel/cert.pem
key = /etc/stunnel/cert.key
client = yes

[ZAB]

accept = 10051
connect = xxx.xxx.xxx.xxx:11612

if you want a systemd config service file you can use the following file
make it in /etc/systemd/system/stunnel.service:

; systemd for stunnel
; /etc/systemd/system/stunnel.service of /usr/lib/systemd/system/stunnel.service
[Unit]
Description=SSL tunnel for network daemons
After=syslog.target
[Service]
ExecStart=/bin/stunnel /etc/stunnel/stunnel.conf
ExecStop=kill -9 $(pgrep stunnel)
ExecStatus=pgrep stunnel
Type=forking
[Install]
WantedBy=multi-user.target

Make sure stunnel starts at reboot and start the service:

systemctl enable stunnel
systemctl start stunnel

Next up, is we need to add the server in the zabbix web page.
Go to Administration, Proxies, Add Proxy, Give your proxy a name and choose proxy mode Active (proxy takes initiative)
ZabbixProxy
We need to have a port per proxy and we want to and open it up in our router (where the zabbix server is installed).
So in the proxy configuration of Zabbix, we need to point to it’s own local ip adress or 127.0.0.1, Stunnel listens on this local port, encrypts it using the certificate and then forwards it to the ip adress we choose in the stunnel config file.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.