Self-Host Gotify on VPS: Automated Push Notification System to Android via API
Self-hosting Gotify on a VPS enables you to build a secure, customizable push notification system that sends alerts directly to Android devices using a REST API. With a lightweight,...
Self-hosting Gotify on a VPS enables you to build a secure, customizable push notification system that sends alerts directly to Android devices using a REST API. With a lightweight, Docker-based architecture, Gotify is ideal for businesses or individuals seeking full control over their notification infrastructure. This guide covers the entire setup process, from deployment and configuration to API testing and security hardening, ensuring reliable message delivery to Android clients.
Introduction to Gotify and Benefits of Self-Hosting
Gotify is an open-source notification platform that allows users to send push notifications to mobile devices via a REST API. Unlike cloud-based services like Firebase, Gotify runs on your own server, ensuring data privacy, full control over message content, and independence from third-party dependencies. Its Docker-ready design makes deployment on a VPS or physical server straightforward. Gotify supports user roles, notification groups, and rich message formatting, including images, sounds, and action buttons.
To get started, you need a VPS capable of running Docker. Suitable options include NVMe Cloud VPS for Docker, Nginx & Databases or High-Performance Dedicated Servers for Production Clusters. Gotify can be used to send alerts from internal applications, monitoring systems, or automation scripts.
Deploy Gotify on VPS Using Docker
Follow these steps on an Ubuntu-based VPS to self-host Gotify:
1. Install Docker if not already present:
sudo apt update
sudo apt install docker.io docker-compose -y
2. Create directories for configuration and data persistence:
mkdir -p ~/gotify/data
mkdir -p ~/gotify/config
3. Create a `docker-compose.yml` file in the current directory:
version: '3.8'
services:
gotify:
image: gotify/server:latest
container_name: gotify
ports:
- "8080:8080"
volumes:
- ./data:/var/gotify/data
- ./config:/var/gotify/config
restart: unless-stopped
environment:
- GOTIFY_SERVER_PORT=8080
- [email protected]
- GOTIFY_SERVER_LOGLEVEL=info
4. Start the service:
docker-compose up -d
Once running, access the admin interface at http://. Log in with your admin credentials and create a new application to obtain an API token.
Integrate with Android Devices and Send Notifications via API
To receive notifications on Android, users must install the Gotify app from Google Play. In the app, enter your VPS address (e.g., http://your-vps-ip:8080) and paste the API token.
Send notifications using the Gotify API. For example, with curl:
curl -X POST http://your-vps-ip:8080/message \
-H "X-Gotify-Key: your_api_token" \
-H "Content-Type: application/json" \
-d '{
"title": "System Alert",
"message": "This is a push notification from your VPS.",
"priority": 5
}'
The API supports fields like title, message, priority, image, and actions for customizing messages. Libraries in Python, Node.js, or PowerShell can automate notifications from external services.
Testing and Security Hardening
Verify the system works by:
- Accessing the admin panel to confirm Gotify is running.
- Sending a test message via API and checking the Android device.
- Setting up Nginx as a reverse proxy to secure port 8080 and enable HTTPS via Let's Encrypt.
For security:
- Change the default admin password.
- Do not expose port 8080 publicly; use a reverse proxy with HTTPS.
- Use separate API tokens for each application to limit access.
Troubleshooting and References
If notifications fail, check:
- API token correctness.
- Correct VPS address in the Android app.
- Firewall rules allowing access to port 8080 (or the proxy port).
- Gotify container logs for errors.
Refer to the official Gotify documentation at https://gotify.net/docs for advanced configuration and API details.
Related infrastructure & engineering guides: Self-Host Ghost CMS on Docker: Optimized SEO Blog & Professional Email Newsletter Platform
Recommended NVMe Cloud VPS Plans to Deploy This Setup
Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.
VPS-3E
10% VAT included
- CPU: 2 vCPU
- RAM: 4 GB
- SSD: 50 GB NVMe
