Skip to content

Web services

This chapter explains what the Zabbix Web service component is why you may need or consider it, what the requirements are and finally how to install it..


What is the Zabbix web service?

The Zabbix web service is an optional component that can be deployed on the same server as the Zabbix server, proxy, frontend or on a separate server. The web service is responsible for handling certain tasks that require a headless browser.

Currently the Zabbix web service is primarily used for generating and sending scheduled reports, but there are plans to expand its functionality in future releases of Zabbix.

The actual usage of the Zabbix web service to generate reports is covered in the Scheduled reports chapter.

zabbix-web-service-overview

3.1 Zabbix web service overview


Zabbix web service requirements

The Zabbix web service requires a linux-based operating system and a headless Google Chrome or Chromium.

Google Chrome vs Chromium

Both Google Chrome and Chromium are supported by the Zabbix web service. However, Google Chrome is a proprietary browser developed by Google, while Chromium is an open-source project that serves as the basis for Google Chrome. Depending on your organization's policies and preferences, you may choose one over the other.

Known Chromium issue on Ubuntu 20-based distributions

There is a known issue on Ubuntu 20 where Zabbix web service will be unable to start Chronium because the Ubuntu-packaged version of Chromium is not allowed to use home directories outside of /home. However, by default, the zabbix-user, configured by the Zabbix web service package, uses /var/lib/zabbix as its home directory, which causes Chromium to fail to start on such distributions.

The system you choose to install the Zabbix web service on should meet the requirements as outlined in the Getting Started: Requirements chapter and should have sufficient resources to run a headless browser. The exact resource requirements will depend on the number of reports you plan to generate and the complexity of those reports. As a general guideline, we recommend at least 2 CPU cores and 4 GB of RAM for a system that will be used to generate reports for a small to medium-sized Zabbix installation.

Installing Google Chrome or Chromium on your system will pull in additional dependencies, such as Qt libraries, audio/video codecs, OpenGL libraries, font rendering libraries, and others. Depending on how you installed your linux operating system, many of these dependencies are probably not yet installed on your system. All together, these dependencies may require up to 1 Gb of additional disk space on your system disk.

This may also be a reason to choose a separate system for the Zabbix web service installation, especially if you are installing Zabbix server or proxy on a minimal system and want to keep those systems clean and minimal.

Alternatively, you can also run the Zabbix web service as a container using Podman or Docker, which includes a headless browser in the container image and keep you host system clean of all those dependency packages.


Installing the Zabbix web service

The Zabbix web service can be installed using packages provided by Zabbix or can be run as a container using Podman or Docker. We will cover both methods in the chapter, starting with the package installation.

As with other Zabbix components, the Zabbix web service can be installed on the same system as the Zabbix server, proxy or frontend, or on a separate system. If you choose to install it on a separate system, ensure that the system meets the requirements as outlined in the Getting Started: Requirements.


Installing the Zabbix web service package

Before we can install the Zabbix web service package, we need to prepare the server for Zabbix installation as outlined in the Preparing the server for Zabbix chapters.

When the system is ready and know where to find the Zabbix software packages, we can proceed with the installation of the Zabbix web service package. The package is named zabbix-web-service and can be installed using the package manager of your operating system.

Install zabbix-web-service package

Red Hat

dnf install zabbix-web-service

SUSE

zypper install zabbix-web-service

Ubuntu

sudo apt-get install zabbix-web-service

As mentioned before, the Zabbix web service requires a headless Google Chrome or Chromium browser to be installed on the system. If you do not have it installed already, you can install it using the package manager of your operating system.

Install Chromium browser

To be able to install Chromium on Red Hat-based systems, you may need to install and enable the EPEL repository first. This is not required for Fedora.

Red Hat

dnf install --enablerepo=epel chromium

To be able to install Chromium on SLES-based systems, you may need to install and enable the SUSE Package Hub repository first. This is not required for openSUSE.

SUSE

zypper install chromium

Ubuntu

sudo apt-get install chromium-browser

Alternatively, you can also install Google Chrome by downloading the package from the Google Chrome website and installing it using the package manager of your operating system.

Configuring the Zabbix web service

Now that the Zabbix web service package and a headless browser are installed, we need to configure the Zabbix web service to allow Zabbix server to make requests to the web service. This is done by editing the /etc/zabbix/zabbix_web_service.conf configuration file.

For now, the only configuration parameter that needs to be set is the AllowedIP parameter, which defines the IP addresses that are allowed to connect to the Zabbix web service. That is, if you have installed the web service on a separate system than the Zabbix server or proxy:

Edit zabbix_web_service.conf

SUSE only: On SUSE 16 and later, the configuration file is installed at /usr/etc/zabbix/zabbix_web_service.conf and needs to be copied to /etc/zabbix/ before editing:

cp /usr/etc/zabbix/zabbix_web_service.conf /etc/zabbix/

sudo vi /etc/zabbix/zabbix_web_service.conf
AllowedIP=<IP_ADDRESS_OF_ZABBIX_SERVER>

Starting the Zabbix web service

Now that the Zabbix web service is installed and configured, we can start the service using the SystemD service manager.

Start Zabbix web service

sudo systemctl enable zabbix-web-service --now

After this, the Zabbix web service should be up and running and ready to accept connections on port 10053 (by default) from the Zabbix server.


Installing the Zabbix web service as a container

The Zabbix web service can also be run as a container using Podman or Docker. This method does not require a separate installation of a headless browser, as the container image already includes one. This reduces the number of extra packages you need to install on your system.

Before we can install and run the Zabbix web service container, we need to prepare the system for running containers as outlined in the Getting Started: Preparation chapter.

Once the system is ready for running containers, we can proceed with creating a .container systemd unit file for the Zabbix web service container. This file should be created in the ~/.config/containers/systemd/ directory of the user podman (or whatever user you have chosen to run the containers as).

Ensure you are logged in as user podman.

Switch to user podman

sudo -u podman -i
Creation of a .container systemd unit file
vi ~/.config/containers/systemd/zabbix-web-service.container
[Unit]
Description=Zabbix Web Service Container

[Container]
Image=docker.io/zabbix/zabbix-web-service:7.0-centos-latest
ContainerName=ZabbixWebService-Quadlet
AutoUpdate=registry
EnvironmentFile=ZabbixWebService.env
PublishPort=10053:10053

[Service]
Restart=always

[Install]
WantedBy=default.target

The Zabbix web service container image is available on Docker Hub. Specifically, we are using the image tagged 7.0-centos-latest in this example, which is maintained by the Zabbix team and is based on CentOS.

Next, we need to create an environment file that will be used to configure the Zabbix web service container. This file should be created in the same directory as the .container unit file and should be named ZabbixWebService.env, as referenced in the unit file above.

This environment file allows us to override default container settings by specifying environment variables used during container runtime. The list of supported variables and their functions is clearly documented on the container's Docker Hub page.

Creation of the environment file
vi ~/.config/containers/systemd/ZabbixWebService.env
# IP address or DNS name of the Zabbix server
ZBX_ALLOWEDIP=<IP_ADDRESS_OF_ZABBIX_SERVER>

With our configuration now complete, the final step is to reload the systemd user daemon so it recognizes the new Quadlet unit. This can be done using the following command:

Reload SystemD user daemon

systemctl --user daemon-reload

If everything is set up correctly, systemd will automatically generate a service unit for the container based on the .container file. You can verify that the unit has been registered by checking the output of systemctl --user list-unit-files:

Verify if the new unit is registered correctly
podman@localhost:~> systemctl --user list-unit-files | grep zabbix
zabbix-web-service.service             generated -

Now you can start the Zabbix web service container using the systemctl --user start command.

Start Zabbix web service container

systemctl --user start zabbix-web-service

After this, the Zabbix web service container should be up and running and ready to accept connections on port 10053 (by default) from the Zabbix server.

This command may take a few minutes as it wil download the required Zabbix Web service container from the docker registry.

To verify that the container started correctly, you can inspect the running containers with:

Inspect running containers
podman@localhost:~> podman ps
CONTAINER ID  IMAGE                                                   COMMAND               CREATED       STATUS       PORTS                     NAMES
bfedb5d16505  docker.io/zabbix/zabbix-web-service:7.0-centos-latest    /usr/sbin/zabbix_...  12 minutes ago  Up 12 minutes  0.0.0.0:10053->10053/tcp  ZabbixWebService-Quadlet

Take note of the CONTAINER ID—in this example, it is b5716f8f379d. You can then retrieve the container's logs using:

Retrieve container logs

podman logs bfedb5d16505
Where bfedb5d16505 is the CONTAINER ID of your container

On some distributions, you can also view the logs directly through SystemD:

journalctl --user -u zabbix-web-service.service

This command will return the startup and runtime logs for the container, which are helpful for troubleshooting and verifying that the Zabbix web service has started correctly.

Upgrading the Zabbix web service container

If, in the future, you need to update the Zabbix web service container to a newer version, you can do so by pulling the latest image from Docker Hub and then restarting the container. Refer to the Running Proxies as containers chapter where we discuss updating containers in more detail including a way to automate the process.


Firewall configuration

For the Zabbix server to communicate with the Zabbix web service, the firewall on the system where the web service is installed must allow incoming connections on the port used by the web service. By default, this is port 10053. If you have changed the port in the Zabbix web service configuration, ensure that the firewall allows incoming connections on the new port.

Configure firewall for Zabbix web service

Red Hat / SUSE

sudo firewall-cmd --add-service=zabbix-web-service --permanent
sudo firewall-cmd --reload

Ubuntu

sudo ufw allow 10053/tcp


Zabbix server configuration

Finally, we need to configure the Zabbix server to use the Zabbix web service for generating scheduled reports. This is done by editing the Zabbix server configuration. If you followed the instructions for using separate config files in /etc/zabbix/zabbix_server.d in the Installing the Zabbix server chapter, you can do this by creating or editing the /etc/zabbix/zabbix_server.d/web_service.conf file.

Edit zabbix_server.d/web_service.conf

sudo vi /etc/zabbix/zabbix_server.d/web_service.conf
# Number of report writers to start. Set to 1 or more depending on the
# expected load. Minimum is 1 to enable report writing functionality.
StartReportWriters=1 

# Zabbix web service IP address or DNS name
WebServiceURL=http://<ZABBIX_WEB_SERVICE_IP_OR_DNS>:10053/report

If you have SELinux enabled on your Zabbix server, you may also need to allow the Zabbix server to make network connections for it to be able connect to the Zabbix web service. This can be done using the following command:

Allow Zabbix server to connect to Zabbix web service with SELinux

sudo setsebool -P zabbix_can_network=1

After making these changes, restart the Zabbix server to apply the new configuration.

Restart Zabbix server

sudo systemctl restart zabbix-server

Finally, you have to tell Zabbix where to find the Zabbix Frontend so that it can generate the reports correctly. This is done in the Frontend itself by navigating to

Administration → General → Other

and setting the

  • Frontend URL parameter to the full URL of your Zabbix Frontend.

With this, we have completed the installation and configuration of the Zabbix web service and integrated it with the Zabbix server. The Zabbix web service is now ready to generate scheduled reports as configured in the Zabbix server.


Conclusion

This chapter has covered the installation and configuration of the Zabbix web service which is an essential component for generating scheduled reports in Zabbix. Whether you choose to install it as a package or run it as a container, we've learned how to set it up and ensure it is properly configured so that the Zabbix server can communicate with it.


Questions

  • What is the primary function of the Zabbix web service?
  • What are the system requirements for installing the Zabbix web service?
  • How do you configure the Zabbix web service to allow connections from the Zabbix server?
  • Should I choose to install the Zabbix web service as a package or run it as a container? Why?

Useful URLs