How to Set Up Zabbix Monitoring on DigitalOcean with Docker and SSL

Zabbix is a robust open-source monitoring platform that helps organizations track server performance, application health, and network infrastructure in real-time. This tutorial will guide you step-by-step through the process of installing and configuring Zabbix on a DigitalOcean Droplet running Ubuntu 24.04 LTS, using Docker containers, a PostgreSQL database, NGINX as a reverse proxy, and Certbot for SSL encryption.

By following this guide, you’ll set up a secure Zabbix server with a fully functional web interface, ideal for monitoring your IT infrastructure in a production environment.

Prerequisites

  • A DigitalOcean Droplet running Ubuntu 24.04 LTS (2GB RAM recommended).
  • A domain name (e.g., yourdomain.com) pointing to your droplet’s IP address.
  • Docker and Docker Compose installed on your droplet.
  • A DigitalOcean Managed PostgreSQL database for storing Zabbix data.
  • NGINX installed as a reverse proxy.
  • Certbot for SSL certificate installation.

Firewall Setup: Ensure your droplet’s firewall allows traffic on ports 80 (HTTP), 443 (HTTPS), and the specific Zabbix ports.

Step 1: Set Up Your DigitalOcean Environment

1.1 Create a DigitalOcean Droplet

Log in to your DigitalOcean control panel and create a droplet with Ubuntu 24.04 LTS. Select a droplet with at least 2GB RAM and SSD storage for optimal performance.

1.2 Create and Configure Managed PostgreSQL

  1. In your DigitalOcean control panel, create a Managed PostgreSQL database cluster.
  2. Record the following connection details for Zabbix setup:
    • Host: your-db-host-name.do-db.ondigitalocean.com
    • Port: 25060
    • Database Name: zabbixdb
    • Username: dbadmin
    • Password: your-db-password
    • SSL Mode: require

Step 2: Install Docker on Ubuntu 24.04 LTS


# Update package list
sudo apt-get update

# Install dependencies
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

# Add Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

# Set up stable repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

# Update apt package list again
sudo apt-get update

# Install Docker CE (Community Edition)
sudo apt-get install docker-ce

# Verify Docker installation
docker --version

# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

# Apply executable permissions to Docker Compose binary
sudo chmod +x /usr/local/bin/docker-compose

# Verify Docker Compose installation
docker-compose --version

Step 3: Create Docker Containers for Zabbix Services

3.1 Zabbix Agent


docker run -d \
  --name newzabbix-agent \
  --restart always \
  -e ZBX_HOSTNAME=zabbix-server \
  -e ZBX_SERVER_HOST=127.0.0.1 \
  -e ZBX_SERVER_PORT=10051 \
  -e ZBX_SERVER_ACTIVE=127.0.0.1 \
  zabbix/zabbix-agent2:latest

3.2 Zabbix SNMP Traps


docker run -d \
  --name zabbix-snmptraps \
  --restart always \
  -e ZBX_HOSTNAME=zabbix-server \
  -e ZBX_SERVER_HOST=127.0.0.1 \
  -e ZBX_SERVER_PORT=10051 \
  -e ZBX_SERVER_ACTIVE=127.0.0.1 \
  -p 1162:1162/udp \
  zabbix/zabbix-snmptraps:latest

3.3 Zabbix Java Gateway


docker run -d \
  --name zabbix-java-gateway \
  --restart always \
  -p 10052:10052 \
  zabbix/zabbix-java-gateway:latest

3.4 Zabbix Web Service


docker run -d \
  --name zabbix-web-service \
  --restart always \
  -p 10053:10053 \
  zabbix/zabbix-web-service:latest

3.5 Zabbix Server


docker run -d \
  --name zabbix-server \
  --link newzabbix-agent:zabbix-agent \
  --link zabbix-snmptraps:zabbix-snmptraps \
  --link zabbix-java-gateway:zabbix-java-gateway \
  --link zabbix-web-service:zabbix-web-service \
  --restart always \
  -p 10051:10051 \
  -e DB_SERVER_HOST=your-db-host-name.do-db.ondigitalocean.com \
  -e DB_SERVER_PORT=25060 \
  -e POSTGRES_DB=zabbixdb \
  -e POSTGRES_USER=dbadmin \
  -e POSTGRES_PASSWORD=your-db-password \
  -e POSTGRES_SSLMODE=require \
  zabbix/zabbix-server-pgsql:latest

3.6 Zabbix Web Frontend


docker run -d \
  --name zabbix-web \
  --restart always \
  --link zabbix-server:zabbix-server \
  -p 2345:8080 \
  -e DB_SERVER_HOST=your-db-host-name.do-db.ondigitalocean.com \
  -e DB_SERVER_PORT=25060 \
  -e POSTGRES_DB=zabbixdb \
  -e POSTGRES_USER=dbadmin \
  -e POSTGRES_PASSWORD=your-db-password \
  -e POSTGRES_SSLMODE=require \
  -e ZBX_SERVER_HOST=zabbix-server \
  zabbix/zabbix-web-nginx-pgsql:latest

Step 4: Configure NGINX as a Reverse Proxy

4.1 Configure NGINX


sudo nano /etc/nginx/sites-available/zabbix

Add the following configuration:


server {
    listen 80;
    server_name yourdomain.com;

    location / {
        proxy_pass http://localhost:2345;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

4.2 Enable the Site


sudo ln -s /etc/nginx/sites-available/zabbix /etc/nginx/sites-enabled/

4.3 Restart NGINX


sudo systemctl restart nginx

Step 5: Install Certbot for SSL

5.1 Install Certbot


sudo apt-get install certbot python3-certbot-nginx

5.2 Obtain SSL Certificates


sudo certbot --nginx -d yourdomain.com

Step 6: Access the Zabbix Web Interface

Now, open your browser and navigate to:


https://yourdomain.com

You should be greeted with the Zabbix login page. The default credentials are:

  • Username: Admin
  • Password: zabbix

Make sure to change the password immediately after logging in for security reasons.

Updating Zabbix

To update Zabbix to the latest version, follow these steps:


# Pull the latest Docker images for Zabbix
docker pull zabbix/zabbix-server-pgsql:latest
docker pull zabbix/zabbix-web-nginx-pgsql:latest

Next, stop and remove the existing containers:


docker stop zabbix-server
docker rm zabbix-server
docker stop zabbix-web
docker rm zabbix-web

Finally, recreate the containers with the updated images:


docker run -d \
  --name zabbix-server \
  --link newzabbix-agent:zabbix-agent \
  --link zabbix-snmptraps:zabbix-snmptraps \
  --link zabbix-java-gateway:zabbix-java-gateway \
  --link zabbix-web-service:zabbix-web-service \
  --restart always \
  -p 10051:10051 \
  -e DB_SERVER_HOST=your-db-host-name.do-db.ondigitalocean.com \
  -e DB_SERVER_PORT=25060 \
  -e POSTGRES_DB=zabbixdb \
  -e POSTGRES_USER=dbadmin \
  -e POSTGRES_PASSWORD=your-db-password \
  -e POSTGRES_SSLMODE=require \
  zabbix/zabbix-server-pgsql:latest

docker run -d \
  --name zabbix-web \
  --restart always \
  --link zabbix-server:zabbix-server \
  -p 2345:8080 \
  -e DB_SERVER_HOST=your-db-host-name.do-db.ondigitalocean.com \
  -e DB_SERVER_PORT=25060 \
  -e POSTGRES_DB=zabbixdb \
  -e POSTGRES_USER=dbadmin \
  -e POSTGRES_PASSWORD=your-db-password \
  -e POSTGRES_SSLMODE=require \
  -e ZBX_SERVER_HOST=zabbix-server \
  zabbix/zabbix-web-nginx-pgsql:latest

This ensures that you’re using the latest Zabbix containers with the updated configuration.

 docker restart zabbix-server docker restart zabbix-web 

<

h2>

Conclusion

By following the steps outlined above, you have successfully installed and configured Zabbix on Docker with a PostgreSQL database backend. You’ve also learned how to update Zabbix by pulling the latest Docker images, stopping and removing the old containers, and recreating them with updated versions. This ensures that your monitoring environment remains up-to-date and secure.

With Zabbix running in Docker containers, managing, scaling, and updating your monitoring system becomes much more streamlined. You can now begin to leverage Zabbix’s powerful features for performance monitoring, alerting, and more, providing better insights into your systems’ health and performance.

If you encounter any issues or need further assistance, don’t hesitate to consult the official Zabbix documentation or reach out to the community for support.

Leave a Reply