Back to articles
Technology Insight

Building a Centralized Notification System with Gotify on a VPS for Automated Script Alerts

May 29, 2026

Introduction: The Need for Centralized Alerting in Enterprise Automation

In modern enterprise IT infrastructure and DevOps workflows, automated scripts handle critical tasks ranging from database backups to system health monitoring. However, automation is only as reliable as its error-reporting mechanism. Relying on traditional email notifications often leads to alert fatigue, while public instant-messaging integrations may raise compliance and data privacy concerns.

To maintain operational efficiency, businesses require a dedicated, secure, and self-hosted solution. Gotify offers an exceptional answer: a lightweight, open-source notification server designed specifically for sending and receiving push notifications via a simple REST-API. This article provides a comprehensive, production-grade guide to deploying a centralized Gotify instance on a Virtual Private Server (VPS) and integrating it into your automated business scripts.

---

Why Choose Gotify for Business Infrastructure?

When engineering an internal monitoring ecosystem, Gotify introduces several strategic advantages over third-party alternatives like Slack or Pushover:

  • Complete Data Sovereignty: As a self-hosted platform, Gotify ensures that proprietary logs, system metrics, and alert data remain entirely within your private infrastructure.
  • Minimal Resource Footprint: Written in Go, Gotify is highly efficient, typically consuming less than 50 MB of RAM, allowing it to run smoothly alongside existing services on a standard VPS.
  • Simplified Integration: With its straightforward HTTP REST-API, any script capable of executing a network request (such as curl or wget) can instantly dispatch alerts.
  • Granular Control with Message Priorities: Gotify utilizes a priority scale ranging from 0 to 10. This allows administrators to differentiate between routine logs (low priority) and system failures requiring immediate intervention (high priority).
---

Architecture Overview and Prerequisites

For a resilient, production-ready environment, we will deploy Gotify utilizing a containerized structure backed by a reverse proxy. This ensures isolated dependencies, easy updates, and secure, encrypted communication.

Prerequisites

Before proceeding, ensure your environment meets the following requirements:

  1. A Linux-based VPS (Ubuntu 22.04 LTS or newer recommended) with a public IP address.
  2. A fully qualified domain name (FQDN) configured with an A Record pointing to your VPS IP address (e.g., gotify.yourcompany.com).
  3. Docker Engine and Docker Compose installed on the host system.
  4. Administrative access (root or a user with sudo privileges).
---

Step-by-Step Deployment Guide

1. Constructing the Docker Compose Environment

To separate configurations and maintain absolute clarity, we will establish a dedicated project directory and manage our deployment via docker-compose.yml.

Execute the following commands to initialize the directory structure:

sudo mkdir -p /opt/gotify
cd /opt/gotify
sudo mkdir -p gotify_data

Next, create the configuration file using your preferred text editor:

sudo nano docker-compose.yml

Populate the file with the following production-optimized definition:

version: "3.8"

services:
  gotify:
    image: gotify/server:latest
    container_name: gotify_server
    restart: unless-stopped
    ports:
      - "127.0.0.1:8080:80"
    environment:
      - TZ=UTC
      - GOTIFY_DEFAULTUSER_NAME=admin
      - GOTIFY_DEFAULTUSER_PASS=InitialSecurePassword123!
      - GOTIFY_REGISTRATION=false
    volumes:
      - ./gotify_data:/app/data

Note: Binding the port explicitly to 127.0.0.1:8080 ensures that the Gotify HTTP service is not exposed directly to the public internet, forcing all external traffic through our secure reverse proxy.

2. Provisioning Security via Nginx and Let's Encrypt

To guarantee token confidentiality and data integrity during transmission, implementing Transport Layer Security (TLS) is mandatory. We will use Nginx as a reverse proxy alongside Certbot for automated SSL lifecycle management.

Install Nginx and Certbot on your host system:

sudo apt update
sudo apt install nginx certbot python3-certbot-nginx -y

Create an Nginx server block configuration for your domain:

sudo nano /etc/nginx/sites-available/gotify.conf

Insert the following configuration, making sure to replace the placeholder domain name with your actual FQDN:

server {
    listen 80;
    server_name gotify.yourcompany.com;

    location / {
        proxy_pass [http://127.0.0.1:8080](http://127.0.0.1:8080);
        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;

        # Support WebSocket connections for real-time delivery
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }
}

Enable the site and verify your syntax by executing:

sudo ln -s /etc/nginx/sites-available/gotify.conf /etc/nginx/sites-enabled/
sudo nginx -t

If the test completes successfully, restart Nginx and invoke Certbot to acquire and install your Let's Encrypt SSL certificate:

sudo systemctl restart nginx
sudo certbot --nginx -d gotify.yourcompany.com
---

Initializing and Configuring the Gotify Workspace

Launch your Gotify container in detached mode:

cd /opt/gotify
sudo docker compose up -d

Now, navigate to your configured domain ([https://gotify.yourcompany.com](https://gotify.yourcompany.com)) using a web browser. Log in using the default administrative credentials defined in your configuration file. Crucial Security Step: Navigate immediately to the "Users" panel within the administrative interface and alter the default administrator credentials to a strong, high-entropy password.

Creating Application Tokens

Gotify separates notification channels using Applications. Each application possesses a unique token, isolating security contexts and allowing you to identify which script generated an alert.

  1. Navigate to the Apps tab in the upper navigation menu.
  2. Click Create Application.
  3. Input a highly descriptive name (e.g., Backup-Monitor or System-Health-Bot).
  4. Save the application and safely document the generated App Token (a string of alphanumeric characters used for API authentication).
---

Script Integration: Real-World Use Cases

Once your applications and tokens are configured, you can integrate Gotify alerts directly into your bash scripts.

Case 1: Automated Database Backup Validation

The following production script executes an enterprise database backup operation, evaluates the exit status, and dispatches a prioritized alert regarding the outcome:

#!/bin/bash

# Configuration
GOTIFY_URL="[https://gotify.yourcompany.com/message](https://gotify.yourcompany.com/message)"
APP_TOKEN="A1b2C3d4E5f6G7"
BACKUP_DIR="/var/backups/db"
DATE=$(date +"%Y-%m-%d_%H%M%S")
LOG_FILE="/tmp/backup_${DATE}.log"

mkdir -p "$BACKUP_DIR"

# Execute Database Dump
pg_dump enterprise_db > "${BACKUP_DIR}/db_${DATE}.sql" 2> "$LOG_FILE"

if [ $? -eq 0 ]; then
    # Success Notification (Priority 3 - Low/Informational)
    curl -X POST -s \
        -F "title=Backup Successful" \
        -F "message=The database backup for enterprise_db completed successfully at ${DATE}." \
        -F "priority=3" \
        "${GOTIFY_URL}?token=${APP_TOKEN}" > /dev/null
else
    # Failure Notification (Priority 8 - High/Alert)
    ERR_MSG=$(tail -n 3 "$LOG_FILE")
    curl -X POST -s \
        -F "title=CRITICAL: Backup Failed" \
        -F "message=The database backup failed. Error context: ${ERR_MSG}" \
        -F "priority=8" \
        "${GOTIFY_URL}?token=${APP_TOKEN}" > /dev/null
fi

# Cleanup log
rm -f "$LOG_FILE"

Case 2: Infrastructure Storage Threshold Monitoring

This script runs as a cron job, analyzing disk usage and triggering warnings when disk consumption crosses defined operational limits:

#!/bin/bash

GOTIFY_URL="[https://gotify.yourcompany.com/message](https://gotify.yourcompany.com/message)"
APP_TOKEN="X9y8W7v6U5t4S3"
THRESHOLD=85
HOSTNAME=$(hostname)

# Extract current root storage percentage
CURRENT_USAGE=$(df / | grep / | awk '{ print $5 }' | sed 's/%//g')

if [ "$CURRENT_USAGE" -gt "$THRESHOLD" ]; then
    curl -X POST -s \
        -F "title=Warning: High Disk Usage on ${HOSTNAME}" \
        -F "message=Root partition volume usage has breached safe operational parameters. Currently at ${CURRENT_USAGE}%." \
        -F "priority=7" \
        "${GOTIFY_URL}?token=${APP_TOKEN}" > /dev/null
fi
---

Conclusion and Maintenance Best Practices

By establishing Gotify as your centralized alert engine, you ensure rapid, secure, and entirely private notification delivery across your automated enterprise scripts. To keep this framework operational over long production lifecycles, adhere to these key maintenance rules:

  • Automate Container Updates: Periodically pull the latest Gotify server images to stay updated with performance enhancements and vulnerability patches.
  • Enforce Regular Database Backups: Ensure that your backup routines copy the contents of the /opt/gotify/gotify_data directory to a secure, remote storage tier.
  • Configure Client-Side Applications: To receive notifications on your mobile device or desktop, download the official Gotify application from F-Droid or GitHub, enter your server domain, and authenticate securely using your user profile.
Building a Centralized Notification System with Gotify on a VPS for Automated Script Alerts | DPTCloud