Run your own uptime service: Uptime Kuma with Traefik on Laravel Forge
In this post, I will show you how to install Uptime Kuma, an open-source monitoring service, on your server. The post assumes you’re using Laravel Forge, but you can adapt them for other services. The basic workflow will stay the same.
Uptime Kuma can monitor a variety of services. I use it to watch this site for downtime. If there is an issue, Uptime Kuma will sends a notification to my phone via the Pushover Message API.
This post is a follow-up to Analytics a different way. Plausible Analytics on Laravel Forge with Traefik and Docker.. In that post, I wrapped up with a section on how to host a static site using Traefik. That was just a simple example to demonstrate the flexibility of the Traefik system.
This post is just a continuation of that previous post and assumes you followed along with the original post to the point of having Traefik installed on your machine. If so, you can easily add Uptime Kuma to your server.
Why do this?
Search the web for “web site uptime monitoring,” and many options are returned. I’ve tried several of them using both the free and paid tiers. At my company, we’re spending hundreds of dollars annually on uptime monitoring services.
Using a third-party monitoring tool has many upsides. Most importantly, you can assume the monitoring service will always be online. A third-party monitoring service will likely be on a different infrastructure than you use. Also, having a third-party solution means you have one less thing to worry about maintaining. I use Uptime Robot to monitor my utility server, which includes my Uptime Kuma installation. The belt and suspenders works.
But the same spirit that drove me to install and use Plausible Analytics instead of Google Analytics on my personal projects inspired me to try running a monitoring service. I like having control over my data. I also enjoy tinkering and building things. If you can relate, this project is for you too.
Installing Uptime Kuma
I’ll refer to Laravel Forge because it’s what I use, but if you use another service, like Ploi, RunCloud, or ServerPilot, you can get through this. I’ve used Laravel Forge for years and have been happy with it. I have not had a reason to move elsewhere.
As a reminder, the server we set up previously was a Worker Server, which only has PHP pre-installed. We chose Worker Server because it is the simplest server option in Laravel Forge, a service focused on PHP-based apps. We also installed Docker on the server already.
Set up your DNS
Using the server’s IP address, create a DNS record, an A record, pointing to the domain name you want to use. Doing this now allows the new record to propagate while we prepare the app.
Check out the GitHub repo
Let’s look at the repo we’ll be using: https://github.com/johnfmorton/uptime-kuma-with-traefik-for-laravel-forge. The docker-compose.yml
file in my repo is nearly identical to the version in the original Uptime Kuma repo. I don’t want port 3001
exposed in my installation.
Because we’re going to be routing Uptime Kuma with Traefik, we need some additional configuration which is in the docker-compose.traefik.yml
file. You’ll see that we’re exposing the 3001
port to Traefik.
You can use my repo or fork it.
Make a new app
In the Laravel Forge dashboard, open the New Site section. Fill in the Directory Name field. I named mine uptime-kuma
. Select Static HTML as the Project Type and click the Add Site button.
Install Uptime Kuma in the App section by choosing a Git repo.
Enter the repository name, johnfmorton/uptime-kuma-with-traefik-for-laravel-forge
, and choose the main branch.
Uncheck the Install Composer Dependencies checkbox because we are not installing a PHP app. Click Install Repository.
The repo’s code is now on the server. We must update our environmental variables and deployment script before completing the Uptime Kuma installation.
Set up your environmental variables
We need four environmental variables. Only the first is mandatory.
- URL_FOR_TRAEFIK — This is the URL you used when setting up the DNS. It does not include the protocol, i.e.,
https
. See thedocker-compose.traefik.yml
file.
The other variables are used only in the deployment script for logging purposes.
- APP_NAME — I used “Uptime Kuma” for mine.
- GIT_REPO — The URL of the repo.
- BASE_URL — Here is used the full URL.
Update your Uptime Kuma deployment script
Click the App nav item. Update your Deploy Script to the following.
cd /home/forge/uptime-kuma
# We assume Docker has already been installed using the "Install Docker and Docker-Compose" recipe.
# The "Make .env variables available to deploy script" must be checked in Laravel Forge
# Confirm Docker is installed and available
if ! command -v docker &> /dev/null; then
echo "Docker is not installed. Please install Docker and try again."
exit 1
fi
echo "Deploying: ${APP_NAME} at ${BASE_URL}"
echo "commit @${FORGE_DEPLOY_COMMIT} -- ${FORGE_DEPLOY_MESSAGE}"
if [[ $FORGE_MANUAL_DEPLOY -eq 1 ]]; then
echo "This deploy was triggered manually."
fi
git pull origin $FORGE_SITE_BRANCH
if [ -f artisan ]; then
$FORGE_PHP artisan migrate --force
fi
echo "Docker up with docker-compose.yml combined with reverse-proxy/traefik/docker-compose.traefik.yml"
docker-compose -f docker-compose.yml -f reverse-proxy/traefik/docker-compose.traefik.yml up -d --remove-orphans
echo "Deploy complete."
Deploy your Uptime Kuma app
Now click the Deploy Now button in the Laravel Forge dashboard. After the deployment process completes, your URL may return a “Bad Gateway” error while Traefik configures the routing. Give it roughly 20 seconds, and then visit the URL. You should see a screen allowing you to set up an account and configure Uptime Kuma.
Set up notifications
Configuring Uptime Kuma is easy. I suggest creating notifications using Pushover. Uptime Kuma supports Pushover. There is a one-time fee for the app for your phone and another for your computer, but then it just works. See the Pushover pricing page for details.
You can then use the Pushover API just about anywhere. It’s a handy tool for your toolkit.
You should now have your own monitoring service set up.