How to Self-Host ntfy on a VPS (Complete Guide)
Self-hosting ntfy, a lightweight notification service, provides a way to manage your notifications independently and securely. In this guide, weโll walk you through the process of deploying ntfy on a VPS with Docker, covering installation steps, configuration, and best practices. Before you start, ensure you have a VPS provider that offers a competitive pricing plan. Below is a comparison of some popular choices:
| Provider | Price (Monthly) |
|---|---|
| Contabo VPS | 5.99 EUR |
| Hetzner Cloud | 4.15 EUR |
| DigitalOcean | 6 USD |
| Vultr | 6 USD |
| Linode (Akamai Cloud) | 5 USD |
Getting Started
1. Choose Your VPS Provider
First, select a VPS from one of the providers listed above. Each option is reasonably priced and suitable for self-hosting applications like ntfy. For detailed comparisons and the best offerings, check out our full VPS comparison.
2. Set Up Your VPS
Once youโve chosen a provider, create an account and deploy a new VPS instance. You can opt for a basic configuration to start with (1 CPU, 1 GB RAM should suffice). Make sure to choose a Linux distribution such as Ubuntu 20.04 for ease of use.
3. Access Your VPS
Use SSH to connect to your VPS. Open your terminal and run:
ssh root@your_vps_ip
Replace your_vps_ip with the actual IP address of your VPS.
4. Install Docker
Check if Docker is already installed. If not, you can install it as follows:
sudo apt update
sudo apt install docker.io -y
sudo systemctl start docker
sudo systemctl enable docker
To verify that Docker is running correctly, run:
docker --version
5. Set Up ntfy Docker Container
Now, letโs pull the ntfy Docker image and run it. Execute the following command:
docker run -d --name ntfy -p 80:80 -v /path/to/your/config:/app/config ghcr.io/binwiederhier/ntfy:latest
- Replace
/path/to/your/configwith the path where you want to store ntfy configurations. - This command maps port 80 of your VPS to port 80 of the Docker container, allowing you to access ntfy via your VPSโs IP address.
6. Configure ntfy
To configure ntfy, navigate to the configuration folder you specified in the previous command. Here, you can edit config.yaml and set your preferences, such as server name, authentication settings, and more.
cd /path/to/your/config
nano config.yaml
7. Restart the Container
After making your changes, restart the ntfy container for the changes to take effect:
docker restart ntfy
8. Verify Installation
To check if ntfy is running correctly, open a web browser and navigate to http://your_vps_ip. You should see the ntfy interface, indicating that the installation was successful.
Best Practices
- Secure Your VPS: Always change the default passwords and set up a firewall. Consider using tools like
ufwto limit access. - Backups: Regularly back up your data and configurations. You can use cron jobs for automated backups.
- Updates: Keep your Docker images and the system updated to protect against vulnerabilities.
FAQs
How do I access ntfy after installation?
After installing ntfy, you can access it by entering http://your_vps_ip in your web browser. Make sure to replace your_vps_ip with the IP address of your VPS. If you have configured ntfy over HTTPS using a domain and SSL certificate, use https://your_domain instead. This is important for securing your notifications and preventing man-in-the-middle attacks.
Can I customize ntfy notifications?
Yes, ntfy allows you to customize notifications according to your needs. Through the config.yaml file, you can set various parameters, including the notification formats, user authentication options, and even different topics for specific notifications. This lets you tailor the service to meet your specific requirements, making it a versatile tool for notification management.
Is it possible to run ntfy without Docker?
While Docker is the recommended method for deploying ntfy due to its simplicity and flexibility, it is possible to run ntfy directly on your VPS by building it from source. You would need to install Go and its dependencies, download the ntfy source code, and compile it. Running ntfy as a Docker container simplifies the process and encapsulates the environment, making it more reliable and easier to manage. Therefore, itโs highly recommended to use Docker.
By following the steps in this guide, you can easily self-host ntfy on your VPS and enjoy a fully manageable notification system tailored to your needs. Happy self-hosting!