Cachet is an open-source status page system written in PHP that enables you to monitor downtime and system failures within your infrastructure. It features JSON API, event reports, metrics, multiple notification methods, and supports Two-Factor Authentication.
This guide will teach you how to install and run Cachet on an Ubuntu 24.04 server using Docker. Additionally, you will set up Nginx as a reverse proxy and secure Cachet with HTTPS via Certbot and Let’s Encrypt.
Prerequisites
Ensure you meet the following prerequisites before starting:
- Ubuntu 24.04 server.
- A non-root user with administrative privileges.
- A domain name pointed at the server’s IP address.
Installing Docker Engine
Cachet will be run as a container using Docker. Begin by installing the Docker Engine on your Ubuntu system.
Start by installing the necessary packages, ca-certificates
and curl
.
sudo apt install ca-certificates curl
Next, add the GPG key for the Docker repository:
sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc
Proceed to add the Docker repository:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu (. /etc/os-release && echo "VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Update your system’s package index and install Docker Engine with:
sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Verify that the Docker service is running and enabled:
sudo systemctl is-enabled docker sudo systemctl status docker
Setting up User to Run Docker
Add your user to the Docker group to allow non-root execution of containers:
sudo usermod -aG docker your_username
Switch to your user account and test the docker run command:
su - your_username docker run hello-world
If successful, you’ll see the Docker Hello World confirmation:
Installing Cachet with Docker
Follow these steps to download and run Cachet in a Docker container:
Clone the Cachet Docker repository:
git clone https://github.com/cachethq/Docker.git cachet-docker cd cachet-docker
Edit the docker-compose.yml
file with nano:
nano docker-compose.yml
Adjust the ports to 8000 for both the host and the container:
ports: - 8000:8000
Save and close the file.
Build and start the Cachet container:
docker compose build docker compose up
Once run, Cachet will generate a new APP_KEY. Ensure to note it, then terminate the containers with Ctrl+C:
Update docker-compose.yml with the new APP_KEY:
APP_KEY=base64:YourGeneratedAppKey
Save and exit.
Recreate Cachet containers:
docker compose down docker compose up -d
Verify that Cachet is running:
docker compose ps
Setting up Nginx as a Reverse Proxy
Configure Nginx to proxy traffic to Cachet on your server:
Install Nginx:
sudo apt install nginx
Create and edit the server block file:
sudo nano /etc/nginx/sites-available/cachet.conf
Insert the following, replacing your_domain:
server { listen 80; server_name your_domain; location / { proxy_pass http://127.0.0.1:8000; 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; } }
Save and exit the editor.
Enable the configuration and verify:
sudo ln -s /etc/nginx/sites-available/cachet.conf /etc/nginx/sites-enabled/ sudo nginx -t
Restart Nginx:
sudo systemctl restart nginx sudo systemctl status nginx
Securing Cachet with HTTPS
Secure Cachet with HTTPS using Certbot:
Install Certbot:
sudo apt install certbot python3-certbot-nginx
Run Certbot to generate SSL certificates:
sudo certbot --nginx
On completion, SSL certificates reside at /etc/letsencrypt/live/your_domain/, securing Cachet with HTTPS.
Installing Cachet
Navigate to your Cachet instance using https://your_domain in your browser and follow these steps:
In the Setup, select default Database for Cache, Queue, and Session, and enter SMTP details:
Create your first status page and continue:
Create an admin account:
After finishing the setup, access the Cachet dashboard by clicking “Go to dashboard”:
Log in using the admin credentials:
Upon successful login, you will see the Cachet dashboard:
Conclusion
Congratulations! You’ve successfully installed Cachet on an Ubuntu 24.04 server using Docker. You’ve also configured Nginx as a reverse proxy and secured your Cachet instance with HTTPS through Certbot and Let’s Encrypt. You can now monitor your services with Cachet and set up notifications as needed.
Frequently Asked Questions (FAQ)
What is Cachet used for?
Cachet is used for creating status pages that monitor downtime, system failures, and provide notifications for infrastructure and services.
Do I need a domain name for Cachet?
Yes, a domain name is needed for accessing your Cachet instance over the web and to obtain an SSL certificate for HTTPS.
Why use Nginx with Cachet?
Nginx acts as a reverse proxy to handle HTTP requests, improve performance, and handle HTTPS connections securely.
What is Docker’s role in this setup?
Docker allows Cachet to run in an isolated environment, making deployment easier and more consistent.
Is it necessary to use HTTPS?
Using HTTPS enhances security by encrypting data between the server and clients, protecting sensitive information.
How can I update Cachet?
You can update Cachet by pulling the latest changes from its Docker repository and rebuilding your Docker containers.