Setting up a Zabbix Proxy
Zabbix is a great monitoring tool with tons of capabilities. One such capability is the use of proxies. These allow you to monitor other networks in addition to the network that your Zabbix server resides on. For example, if you run Zabbix on a VPS or dedicated server, proxies would allow you to monitor devices on your home or work network.
(Optional) Generating a Pre-Shared Key
A Zabbix proxy can communicate with the Zabbix server without using encryption, but this isn't recommended. Instead, it is best to generate a PSK and use that for encrypted communications. This will be generated on the Zabbix server then copied to the Zabbix proxy.
Installing GNU Utilities
sudo apt install gnutls-bin
Generating the PSK
Once installed, we will generate a new Pre-Shared Key (PSK). If you plan on setting up multiple proxies, it is best to generate a new PSK for each proxy.
psktool -u psk_identity -p zabbix002.psk -s 32
Copying the key
This guide will assume that your Zabbix proxy is not accessible over the internet, so we will be using rsync to pull the zabbix002.psk from the Zabbix server.
sam@zabbix-proxy:~$ rsync "ZABBIX-SERVER-IP":zabbix002.psk zabbix002.psk
If your Zabbix server can connect to the Zabbix proxy via SSH, you can push the PSK instead:
sam@zabbix-server:~$ rsync zabbix002.psk "ZABBIX-PROXY-IP":zabbix002.psk
Installing the Zabbix proxy
Downloading the repository
First, download the Zabbix repository specific to your distribution. I'm using Ubuntu Server 20.04 (Focal) so this is the command:
wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+focal_all.deb
Then install using dpkg:
sudo dpkg -i zabbix-release_5.0-1+focal_all.deb
Update apt package info
sudo apt update
Install zabbix-proxy & mariadb
sudo apt install zabbix-proxy-mysql mariadb-common mariadb-server mariadb-client
Start & enable mariadb
sudo systemctl start mariadb && sudo systemctl enable mariadb
MySQL setup
Securing the installation & setting a new root DB password
sudo mysql_secure_installation
Enter current password for root (enter for none): <Press the Enter key>
Set root password? [Y/n]: Y
New password: <Enter a new root DB password>
Re-enter new password: <Repeat the new root DB password>
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y
Login to MySQL and create a new database & account for the Zabbix proxy
sudo mysql -uroot -p'root DB pass'
mysql> create database zabbix_proxy character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix_proxy.* to zabbix@localhost identified by 'zabbix DB pass';
mysql> quit;
Import the Zabbix database schema
zcat /usr/share/doc/zabbix-proxy-mysql*/schema.sql.gz | mysql -uzabbix -p'zabbix DB pass' zabbix_proxy
Zabbix proxy configuration
First, open the Zabbix proxy config file with your preferred text editor (in this example nano)
sudo nano /etc/zabbix/zabbix_proxy.conf
These are the sections that we need to change:
### Option: Server
# If ProxyMode is set to active mode:
# IP address or DNS name of Zabbix server to get configuration data from and send data >
Server="ZABBIX-SERVER-IP"
### Option: Hostname
# Unique, case sensitive Proxy name. Make sure the Proxy name is known to the server!
# Value is acquired from HostnameItem if undefined.
Hostname=Zabbix proxy 002
### Option: DBPassword
# Database password. Ignored for SQLite.
# Comment this line if no password is used.
DBPassword=zabbix DB pass
The Zabbix proxy needs to connect to TCP port 10051 of the Zabbix server specified above. If the Zabbix server lies within a different network, you will need to create a port forwarding rule.
It is also recommended to set the ConfigFrequency parameter to 100. This will lower the amount of time that it takes the proxy to receive the configuration from the Zabbix server:
### Option: ConfigFrequency
# How often proxy retrieves configuration data from Zabbix Server in seconds.
# For a proxy in the passive mode this parameter will be ignored.
#
# Mandatory: no
# Range: 1-3600*24*7
# Default:
ConfigFrequency=100
If you're using a PSK, you will also need to modify these sections so that they are as follows:
### Option: TLSConnect
# How the proxy should connect to Zabbix server. Used for an active proxy, ignored on a passive>
TLSConnect=psk
### Option: TLSAccept
# What incoming connections to accept from Zabbix server. Used for a passive proxy, ignored on >
TLSAccept=psk
### Option: TLSPSKIdentity
# Unique, case sensitive string used to identify the pre-shared key.
TLSPSKIdentity=zabbix002
### Option: TLSPSKFile
# Full pathname of a file containing the pre-shared key.
TLSPSKFile=/etc/zabbix/zabbix002.psk
Moving the PSK
SSH into the Zabbix proxy, and move the zabbix PSK that we copied earlier to /etc/zabbix:
sam@zabbix-proxy:~$ sudo mv zabbix002.psk /etc/zabbix/
Make Zabbix the owner of the PSK:
sam@zabbix-proxy:~$ sudo chown zabbix:zabbix /etc/zabbix/zabbix002.psk
Set the correct permissions for the PSK:
sam@zabbix-proxy:~$ sudo chmod 644 /etc/zabbix/zabbix002.psk
Starting and enabling the Zabbix proxy service
Now that the configuration file has been modified and the PSK has been moved to the desired location, we can finally start and enable the Zabbix-proxy service using these commands:
sudo systemctl restart zabbix-proxy && sudo systemctl enable zabbix-proxy
Registering the Proxy in the Zabbix web interface
The Zabbix proxy service is now running, and will be trying to connect to the Zabbix server. We need to register it in Zabbix's web interface to allow them to communicate.
First, log into the interface and go to Administration > Proxies then click on the Create proxy button (in the top right):
Give the proxy a name, then click on the Encryption tab. Before configuring this section, go back to the Zabbix proxy and use cat to open the PSK:
sam@zabbix-proxy:~$ cat /etc/zabbix/zabbix002.psk
psk_identity:a9404f7ea49fb1bd17c083ca8b13b5a02abc96035cccca01fb31e78a5be53285
Copy everything listed after the colon, and paste this into the PSK section on the Zabbix interface. The PSK identity should be the same as in the zabbix_proxy.conf. Tick the box next to PSK and untick the "no encryption" box. Click add once finished.
As can be seen below, our Proxy is now active!
Monitoring hosts with the new proxy
So we've added a proxy, but how do we actually get Zabbix to use it?
For individual hosts
Go to Configuration > Hosts then click on a host that you'd like to monitor with the Proxy. At the bottom of the page, you'll see a "Monitored by" section. Change this from "no proxy" to the new proxy that has just been added:
For multiple hosts
As with for single hosts, go to Configuration > Hosts then tick the box next to the hosts that you'd like to change. At the bottom of the page, there is a mass update button. Click that and you can select the new proxy from there.




