Deploying ntfy
Introduction
ntfy (pronounced “notify”) is a simple, HTTP-based pub-sub notification service that lets you send push notifications to your phone or desktop from any script, application, or service. With no signup required and a simple curl command, ntfy makes it trivially easy to add notifications to any workflow.
Built with simplicity as a core principle, ntfy provides a refreshingly straightforward approach to notifications. Whether you want to know when a long-running script completes, receive alerts from your home automation system, or get notified about server events, ntfy handles it with minimal configuration.
Key highlights of ntfy:
- Simple API: Send notifications with a single curl command or HTTP POST
- No Signup Required: Start using immediately without registration
- Mobile Apps: Native Android and iOS apps for push notifications
- Web Interface: Browser-based notification viewing and subscription
- Topic-Based: Subscribe to topics and receive all messages published to them
- Attachments: Send files and images with your notifications
- Actions: Include clickable buttons and actions in notifications
- Priority Levels: Set urgency from min to max with different behaviors
- Scheduled Delivery: Delay message delivery to a specific time
- Message Caching: Messages are stored for later retrieval
- Authentication: Optional access control for private topics
- UnifiedPush: Acts as a UnifiedPush distributor for other apps
- Open Source: Licensed under Apache 2.0
This guide walks through deploying ntfy on Klutch.sh using Docker, configuring the server, and integrating notifications into your workflows.
Why Deploy ntfy on Klutch.sh
Deploying ntfy on Klutch.sh provides several advantages:
Self-Hosted Privacy: Your notifications stay on your infrastructure with no third-party access.
Simplified Deployment: Klutch.sh automatically detects your Dockerfile and builds ntfy without complex configuration.
Persistent Storage: Attach persistent volumes for message cache and user data.
HTTPS by Default: Klutch.sh provides automatic SSL certificates, required for mobile app connections.
GitHub Integration: Connect your configuration repository for automatic redeployments.
Always Available: Your notification server runs 24/7, ready to receive and deliver messages.
Custom Domains: Use your own domain for a professional notification endpoint.
Prerequisites
Before deploying ntfy on Klutch.sh, ensure you have:
- A Klutch.sh account
- A GitHub account with a repository for your configuration
- Basic familiarity with Docker and containerization concepts
- (Optional) The ntfy mobile app for push notifications
- (Optional) A custom domain for your ntfy instance
Understanding ntfy Architecture
ntfy uses a simple pub-sub model:
Topics: Named channels that messages are published to and subscribed from.
Publishers: Any HTTP client that sends messages to topics.
Subscribers: Apps, browsers, or services that receive messages from topics.
Message Cache: Temporary storage for messages to ensure delivery.
Authentication: Optional user system for access control.
Preparing Your Repository
Create a GitHub repository with your ntfy configuration.
Repository Structure
ntfy-deploy/├── Dockerfile├── server.yml└── .dockerignoreCreating the Dockerfile
Create a Dockerfile in your repository root:
FROM binwiederhier/ntfy:latest
# Copy configurationCOPY server.yml /etc/ntfy/server.yml
# Create data directoriesRUN mkdir -p /var/cache/ntfy /var/lib/ntfy
# Set environment variablesENV NTFY_BASE_URL=${NTFY_BASE_URL}ENV NTFY_CACHE_FILE=/var/cache/ntfy/cache.dbENV NTFY_AUTH_FILE=/var/lib/ntfy/auth.db
# Expose HTTP portEXPOSE 80
# Health checkHEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:80/v1/health || exit 1
# Run ntfyCMD ["serve"]Creating the Configuration File
Create server.yml:
# ntfy Server Configuration
# Base URL of the server (required for attachments)base-url: "${NTFY_BASE_URL}"
# Listen addresslisten-http: ":80"
# Cache configurationcache-file: "/var/cache/ntfy/cache.db"cache-duration: "12h"
# Attachment configurationattachment-cache-dir: "/var/cache/ntfy/attachments"attachment-total-size-limit: "5G"attachment-file-size-limit: "15M"attachment-expiry-duration: "3h"
# Authentication databaseauth-file: "/var/lib/ntfy/auth.db"auth-default-access: "read-write"
# Rate limitingvisitor-request-limit-burst: 60visitor-request-limit-replenish: "5s"visitor-attachment-total-size-limit: "100M"visitor-attachment-daily-bandwidth-limit: "500M"
# Logginglog-level: "info"log-format: "json"
# Enable web UIenable-web: true
# Upstream server for UnifiedPush# upstream-base-url: "https://ntfy.sh"
# Behind proxy settingsbehind-proxy: trueCreating the .dockerignore File
.git.github*.mdLICENSE.gitignore*.log.DS_Store.envEnvironment Variables Reference
| Variable | Required | Default | Description |
|---|---|---|---|
NTFY_BASE_URL | Yes | - | Public URL of your ntfy instance |
NTFY_AUTH_DEFAULT_ACCESS | No | read-write | Default access for unauthenticated users |
NTFY_CACHE_DURATION | No | 12h | How long to cache messages |
Deploying ntfy on Klutch.sh
- Select HTTP as the traffic type
- Set the internal port to 80
Push Your Repository to GitHub
Initialize and push your repository with the Dockerfile and configuration.
Create a New Project on Klutch.sh
Navigate to the Klutch.sh dashboard and create a new project called “ntfy”.
Create a New App
Within your project, create a new app and connect your GitHub repository.
Configure HTTP Traffic
In the deployment settings:
Set Environment Variables
Configure the following environment variables:
| Variable | Value |
|---|---|
NTFY_BASE_URL | https://your-app-name.klutch.sh |
Attach Persistent Volumes
Add the following volumes:
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/var/cache/ntfy | 5 GB | Message cache and attachments |
/var/lib/ntfy | 1 GB | Authentication database |
Deploy Your Application
Click Deploy to start the build process.
Access ntfy
Once deployment completes, access your instance at https://your-app-name.klutch.sh.
Test Notifications
Send a test notification to verify everything works.
Sending Notifications
Simple Message
Send a basic notification with curl:
curl -d "Backup completed successfully" https://your-app.klutch.sh/mytopicWith Title and Priority
curl \ -H "Title: Server Alert" \ -H "Priority: high" \ -H "Tags: warning,server" \ -d "CPU usage exceeded 90%" \ https://your-app.klutch.sh/alertsWith Actions
Include clickable buttons:
curl \ -H "Actions: view, Open Dashboard, https://example.com/dashboard; http, Acknowledge, https://example.com/ack" \ -d "New deployment ready for review" \ https://your-app.klutch.sh/deploysWith Attachments
Send a file with your notification:
curl \ -H "Filename: report.pdf" \ -T /path/to/report.pdf \ https://your-app.klutch.sh/reportsScheduled Delivery
Delay message delivery:
curl \ -H "At: tomorrow, 9am" \ -d "Time for your morning standup!" \ https://your-app.klutch.sh/remindersUsing JSON
Send structured notifications:
curl \ -H "Content-Type: application/json" \ -d '{ "topic": "alerts", "title": "Build Failed", "message": "The nightly build failed with 3 errors", "priority": 4, "tags": ["x", "build"], "actions": [ {"action": "view", "label": "View Logs", "url": "https://ci.example.com/logs"} ] }' \ https://your-app.klutch.sh/Subscribing to Notifications
Mobile Apps
- Download the ntfy app from Google Play or App Store
- Add your server URL in settings
- Subscribe to your topics
- Receive push notifications
Web Interface
Access https://your-app.klutch.sh in a browser to:
- View recent notifications
- Subscribe to topics
- Send test messages
- Manage subscriptions
Command Line
Subscribe and print messages:
curl -s https://your-app.klutch.sh/mytopic/json | while read line; do echo "$line" | jq .doneWebSocket
For real-time subscriptions:
const ws = new WebSocket('wss://your-app.klutch.sh/mytopic/ws');ws.onmessage = (event) => { const data = JSON.parse(event.data); console.log('Received:', data.message);};Common Use Cases
Script Completion Alerts
#!/bin/bash# Your long-running script here./backup.sh
# Notify when completecurl -d "Backup finished at $(date)" https://your-app.klutch.sh/backupsServer Monitoring
# Send alert if disk usage exceeds 90%USAGE=$(df -h / | awk 'NR==2 {print $5}' | tr -d '%')if [ "$USAGE" -gt 90 ]; then curl -H "Priority: urgent" \ -d "Disk usage at ${USAGE}%" \ https://your-app.klutch.sh/server-alertsfiCI/CD Notifications
# In your CI/CD pipeline- name: Notify on success run: | curl -H "Title: Build Successful" \ -H "Tags: white_check_mark" \ -d "Build ${{ github.run_number }} completed" \ https://your-app.klutch.sh/buildsHome Automation
Integrate with Home Assistant, Node-RED, or other automation platforms to receive smart home alerts.
Authentication
Creating Users
Use the ntfy CLI to add users:
ntfy user add --role=admin adminntfy user add user1Access Control
Restrict topic access:
ntfy access mytopic user1 read-writentfy access secret-topic everyone denyToken-Based Auth
For scripts, use tokens:
curl -u "user:password" https://your-app.klutch.sh/private-topic# Or with tokencurl -H "Authorization: Bearer your_token" https://your-app.klutch.sh/private-topicTroubleshooting
Notifications Not Arriving
- Verify the topic name matches exactly
- Check mobile app is connected to correct server
- Ensure HTTPS is working (required for mobile)
- Review message cache for undelivered messages
Attachments Failing
- Check attachment size limits
- Verify cache directory permissions
- Ensure sufficient disk space
Authentication Issues
- Verify auth file permissions
- Check user credentials
- Review default access settings
Rate Limiting
- Adjust rate limit settings if needed
- Check visitor limits in configuration
Additional Resources
- ntfy Official Website
- ntfy Documentation
- ntfy GitHub Repository
- Integration Examples
- Klutch.sh Persistent Volumes
- Klutch.sh Deployments
Conclusion
Deploying ntfy on Klutch.sh gives you a powerful, self-hosted notification service that integrates with virtually any workflow. The simple HTTP API means you can add notifications to scripts, monitoring systems, and automation platforms with minimal effort.
With mobile apps for push notifications, a web interface for management, and support for attachments and actions, ntfy on Klutch.sh provides everything needed for a comprehensive notification system. Whether you’re monitoring servers, tracking build pipelines, or receiving smart home alerts, ntfy makes notifications simple and accessible.