Stop using Discord for homelab notifications -- here's what I switched to instead
Company Updates

Stop using Discord for homelab notifications -- here's what I switched to instead

The How-To Geek6d ago

Faisal Rasool has been a feature writer at How-to Geek since early 2024. He brings five years of professional experience in simplifying technology for his readers on topics like mobile devices, PCs, and online privacy. He tries to help people get the most out of their gadgets and software with the least effort.

In his teenage years, he spent hours every day tinkering with Android phones and Linux builds. Faisal started his career at WhatMobile in 2019 (mostly out of his obsession with Android) where he published over 2,000 news stories. Currently, he contributes to the news section over at AndroidHeadlines.

He also authored more than 100 feature articles for SlashGear, covering Android, iOS, Web, Chromebooks, online privacy/security, and PC content.

Faisal is also pursuing a Bachelor's in English literature to build up his writing chops. He enjoys watercolors, classic video games, animated films, and conversations with strangers.

Discord webhooks are how a lot of people get push notifications from their home servers. However, if you find it too laggy or if it's too messy to get all your server notifications on a single channel, there's an even simpler way. This tool allows you to push notifications to your phone with a single curl command.

What is Ntfy A clever service that instantly pushes notifications to as many devices as you want

Ntfy is a free and open-source simple push notification service that you can self-host on your server. It accepts HTTPS requests and instantly pushes them to any device that's connected to your self-hosted Ntfy server. You could include simple curl commands in scripts or cron jobs to receive push notifications.

You can push notifications by "topic." Basically, Ntfy lets you sort and organize notifications into different channels. You could, for example, create a channel for uptime alerts and another for backups. Then you could "subscribe" to either or both of those topics on your phone or tablet to get push notifications.

It's a pretty lightweight setup because it barely consumes any resources, so you can run it on anything that can spin up a Docker container. To receive push notifications, you can download the Ntfy app on Android or iOS devices. You can even get desktop notifications via the browser app (accessible via the server address).

How to set up the server You just need Docker

The simplest and most practical way to set up Ntfy on a server is through the official Ntfy Docker image. If you don't already have Docker installed on your server, you can use the official Bash script to install it.

curl -fsSL https://get.docker.com | sudo sh

It's always a good idea to double-check scripts downloaded from the internet before running them. You can read the contents of that shell script by visiting the URL or use cat to print its contents.

Raspberry Pi 5 Brand Raspberry Pi Storage 8GB CPU Cortex A7 Memory 8GB Operating System Raspbian Ports 4 USB-A

It's only recommended for tech-savvy users, but the Raspberry Pi 5 is a tinkerer's dream. Cheap, highly customizable, and with great onboard specs, it's a solid base for your next mini PC.

$80 at Spark Fun $93 at Amazon $80 at CanaKit Expand Collapse

With Docker installed, we can now use a Docker compose file to spin up a lightweight Ntfy container. Let's create a new directory to keep the Ntfy container and its compose file.

mkdir -p ntfy/{config,cache,data}

Let's create a compose file.

nano docker-compose.yml

Paste this in the compose file. After that, press Ctrl+O and Enter to save it. Then Ctrl+X to exit the nano editor.

services:

ntfy:

image: binwiederhier/ntfy

container_name: ntfy

command: serve

environment:

  • NTFY_BASE_URL=http://192.168.1.50:9000

  • NTFY_LISTEN_HTTP=:80

  • NTFY_CACHE_FILE=/var/cache/ntfy/cache.db

  • NTFY_AUTH_FILE=/etc/ntfy/auth.db

  • NTFY_AUTH_DEFAULT_ACCESS=deny-all

volumes:

  • ./cache:/var/cache/ntfy

  • ./config:/etc/ntfy

ports:

  • "9000:80"

restart: unless-stopped

We can now start the container with this command.

docker compose up -d

Verify that the container is running, and running on the right port.

docker ps

Technically, you don't need a Docker container to set up Ntfy. It can be installed as a simple APT package that runs as a systemd service (so it'll automatically start as soon as the server boots up). However, it can get messy if you plan to move it between servers, or run into dependency issues. Docker containers are easy to migrate and easy to wipe, and you won't run into dependency issues.

How to get Ntfy notifications on your phone Install the app and connect to your server

Basically, you just need the Ntfy app and the URL for accessing the Ntfy instance running on your personal server. You can download Ntfy from F-Droid or Google Play Store for Android and the App Store for iOS.

Launch the app and tap the three dots at the top to open the settings menu. Scroll down to general settings and tap Default server. The address should look something like this. The port is what you chose when creating the Docker container for the Ntfy server.

http://192.168.1.50:9000

Then hit Save.

You can now subscribe to as many "topics" or notification channels coming from the server. Tap the plus button at the bottom. You'll see a "Subscribe to topic" window. The topic name is the address you'll push notifications to from your server. Type it and hit Subscribe.

Since all this is being done over an HTTP connection, pick a unique topic name that's hard to guess because it'll double as your password. If you pick something common like "alerts," anyone connected to your Wi-Fi network could technically pull notifications from your server by subscribing to the same topic.

It should connect to the server right away and show a notification chain on the main menu.

If you see any errors, make sure you type the right server IP and port address. Also make sure you're connected to the same Wi-Fi network as the server. You can set up a reverse proxy or a private network like Tailscale if you want to access your notifications outside your home Wi-Fi network.

Let's test our new setup.

On your server, use a curl command to push a notification to the channel you selected.

curl -d "This is a test alert from my server" http://192.168.1.50:9000/jelly_alerts

The notification should instantly show up in the notification thread, as well as your phone's notification shade.

Some pro tips You can set priority alerts and even send file attachments

There's little use in manually pushing these notifications, but you'll probably want to include these curl calls within your scripts. For example, I've set up a script that uses the Asana API to send me alerts. You can set up a channel for as many scripts as you want. You can also set the priority of the push notifications with these flags.

curl \

-H "Title: Emergency" \

-H "Priority: high" \

-d "Immediate attention needed" \

http://192.168.1.50:9000/jelly_alerts

Then configure the notification priority for Ntfy within the app settings. You can also attach local files or download URLs with the push notifications.

Lightweight and easy push notifications

If you're looking for a simple and lightweight way to push notifications for your backups, API calls, scripts, or uptime monitoring alerts, it doesn't get simpler than the basic curl syntax that Ntfy uses.

Originally published by The How-To Geek

Read original source →
Discord