uptime kuma

Installing Uptime Kuma to keep an eye on your servers

published on

If you would like to monitor the uptime of your servers and websites but Zabbix (Installing and setting up Zabbix 6.4 with OpenResty) is too much then Uptime Kuma may well be an excellent alternative.

Uptime Kuma, which can be found at https://uptime.kuma.pet/ is a great tool and is also easy to install and set up. I will simply combine a few different parts of the installation here for ease of access.

Setting up Uptime Kuma

Installing and setting up Uptime Kuma is a multi-stage process. However, if you follow the below steps you will find it quite easy.

Install Node.js

Run the following commands to install Node.js on your server:

cd ~
curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt install nodejs

These commands will install Node.js version 18. If you want a different version then change the number above.

Install the process manager

This helps to make sure Uptime-Kuma restarts when necessary, amongst other thing. Run sudo npm install pm2 -g && pm2 install pm2-logrotate to install it.

Install Git

If Git isn't already installed then make sure to install it with sudo apt install git.

Install Uptime-Kuma

Now that we have the pre-requisites installed run the following commands to download and install Uptime-Kuma:

git clone https://github.com/louislam/uptime-kuma.git
cd uptime-kuma
sudo npm run setup
pm2 start server/server.js --name uptime-kuma
pm2 save && pm2 startup

Setting up Caddy as the reverse proxy

Once the installation has finished Uptime Kuma will be available on port 3001 by default. You will need to install a reverse proxy to make it accessible to the internet securely.

This can be done using Apache, NGinx, Caddy, Cloudflare or any other reverse proxy. However, here I will show you how to do this using Caddy. Other methods can be found at the Uptime Kuma web site.

Using Ubuntu run the following commands to install the Caddy webserver:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
sudo mkdir /var/log/caddy
sudo chown -R caddy:caddy /var/log/caddy

Now create the Caddyfile (the equivalent to the virtual server or server block of other web servers) by executing

sudo nano /etc/Caddy/Caddyfile

Remove any contents that are already there and add the following three lines (replacing the domain with one of your own)

subdomain.domain.com {
    reverse_proxy 127.0.0.1:3001
}

Restart Caddy with sudo systemctl restart caddy and you should now be able to access your Uptime Kuma installation at the domain name you added to your Caddyfile.

Updating your installation

From time to time you will see that there are updates for your current version of Uptime Kuma.

This can be achieved by connecting to the server that your installation is on and running the following commands:

cd <uptime-kuma-directory>
      Note: The default install path is usually /opt/uptime-kuma
sudo git fetch --all
sudo git checkout [version] --force
sudo npm install --production
sudo npm run download-dist
sudo pm2 restart uptime-kuma

Make sure to change directory to the one that you originally installed Uptime Kuma into. Also make sure to replace [version] above with the version that is displayed in the [new tag] line after running the sudo git fetch --all command.