---
title: "Run your own uptime service: Uptime Kuma with Traefik on Laravel Forge"
date: 2023-08-18T11:13:00-04:00
author: John Morton
canonical_url: "https://supergeekery.com/blog/uptime-kuma-with-traefik-on-laravel-forge"
section: Blog
---
# Run your own uptime service: Uptime Kuma with Traefik on Laravel Forge

*August 18, 2023* by John Morton

![robot-staring-at-computer](https://static.supergeekery.com/site-assets/00001-4029913913.jpg)
*A robot staring intently at a website. the robots has wide eyes like it has been staring at the screen all night long. (Stable Diffusion)*

In this post, I will show you how to install [Uptime Kuma](https://uptime.kuma.pet/), an open-source monitoring service, on your server. The post assumes you're using [Laravel Forge](https://forge.laravel.com/), 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](https://pushover.net/api).

This post is a follow-up to [_Analytics a different way. Plausible Analytics on Laravel Forge with Traefik and Docker._](/blog/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](/blog/plausible-analytics-on-laravel-forge-with-traefik-and-docker#use-traefik-to-host-a-static-site). 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.
![Uptime status Supergeekery](https://static.supergeekery.com/site-assets/uptime-status-supergeekery.png)
*A screenshot of Uptime Kuma monitoring SuperGeekery.com.*
## Why do this?

Search the web for [_"web site uptime monitoring,"_](https://www.google.com/search?q=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](https://uptimerobot.com) to monitor my utility server, which includes my Uptime Kuma installation. The [belt and suspenders](https://www.wordnik.com/words/belt%20and%20suspenders) 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`](https://github.com/johnfmorton/uptime-kuma-with-traefik-for-laravel-forge/blob/main/docker-compose.yml) file in my repo is nearly identical to [the version in the original Uptime Kuma repo](https://github.com/louislam/uptime-kuma/blob/master/docker/docker-compose.yml). 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`](https://github.com/johnfmorton/uptime-kuma-with-traefik-for-laravel-forge/blob/main/reverse-proxy/traefik/docker-compose.traefik.yml) file. You'll [see](https://github.com/johnfmorton/uptime-kuma-with-traefik-for-laravel-forge/blob/7b78e82e3f29a794785420020522ac276e81170f/reverse-proxy/traefik/docker-compose.traefik.yml#L15) 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.

### Logging in with your Docker account

I'm adding an update on Jan 3, 2025. As I went through this process again on a new server, I ran into an issue with the deployment script I will describe next. Docker Hub was refusing to allow my deployment process to complete because of a rate limit it had imposed. To deal with this, I had to log into my Docker Hub account and create and access token. Next, from the command line, logged into the server and logged in with my Docker Hub account, `docker login -u johnfmorton` followed by my access token. After doing this, I was able to complete the steps outlined below.

### 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 the [`docker-compose.traefik.yml`](https://github.com/johnfmorton/uptime-kuma-with-traefik-for-laravel-forge/blob/0b14e7ff2d06c6b6f73b90eae79858a319eef40a/reverse-proxy/traefik/docker-compose.traefik.yml#L9) 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](https://pushover.net/pricing) for details.

You can then use the [Pushover API](https://pushover.net/api) just about anywhere. It's a handy tool for your toolkit.

You should now have your own monitoring service set up. 

---

**Tags:** tutorial, webdev
