Root-Server Tutorial

ROOT-SERVER TUTORIAL

Install Uptime Kuma on Debian

Learn how to install Uptime Kuma on Debian servers

Author:

Zoey Löchner

Last updated:

16/01/2021

Introduction

In this tutorial you will learn how to install Uptime Kuma.

I am doing this on a Debian 11 server (RS Zimtstern) but the installation should also work on other Debian versions.

Requirements

You need Apache2, PHP and MariaDB installed on your server, see here.

Installing Uptime Kuma

Uptime Kuma is an open source monitoring tool. Here is a demo of it.
This tutorial is based on https://github.com/louislam/uptime-kuma/blob/master/README.md

First, we need to install Docker by running the following commands:

apt remove docker docker-engine docker.io containerd runc docker-compose -y
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update && apt install docker-ce docker-ce-cli containerd.io -y
systemctl enable --now docker

Next, install Uptime Kuma with these commands:

docker volume create uptime-kuma
docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1

Now you can open Uptime Kuma by accessing http://IP:3001/ or http://DOMAIN:3001/ (you need to open Port 3001 to the internet beforehand).

In the following commands, replace every DOMAIN with your domain or subdomain.

  • Generate an SSL certificate by running certbot certonly --apache -d DOMAIN.
  • Run nano /etc/apache2/sites-enabled/uk.conf.

Now paste these lines into the file:

<VirtualHost *:443>
    ServerName DOMAIN

    ProxyPass / http://localhost:3001/
    RewriteEngine on
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteCond %{HTTP:Connection} upgrade [NC]
    RewriteRule ^/?(.*) "ws://localhost:3001/$1" [P,L]

    ErrorLog ${APACHE_LOG_DIR}/uk.error.log

    SSLCertificateFile /etc/letsencrypt/live/DOMAIN/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/DOMAIN/privkey.pem
</VirtualHost>
  • Replace every DOMAIN with your domain and set a folder path under "DocumentRoot". All files in this folder will be available on your DOMAIN in the web.
  • Save your changes by pressing CTRL + X, then y and finally by hitting ENTER.
  • Restart Apache2 by executing service apache2 restart.

Note: If you are doing this directly on a domain and NOT on a subdomain, or if you want to make the site available on multiple subdomains, I recommend adding a server alias to the configuration as shown below. (If you want to make this site available on any subdomain that looks like abc, you can add abc.* as a server alias.) For this you need to regenerate the SSL certificate with certbot certonly --apache -d DOMAIN,www.DOMAIN,web.DOMAIN,sub.DOMAIN.

<VirtualHost *:443>
    ServerName DOMAIN
+   ServerAlias status.* uk.DOMAIN

    ProxyPass / http://localhost:3001/
    RewriteEngine on
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteCond %{HTTP:Connection} upgrade [NC]
    RewriteRule ^/?(.*) "ws://localhost:3001/$1" [P,L]

    ErrorLog ${APACHE_LOG_DIR}/uk-error.log

    SSLCertificateFile /etc/letsencrypt/live/DOMAIN/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/DOMAIN/privkey.pem
</VirtualHost>

Step 1.2 - Update Uptime Kuma

Execute the following commands:

docker pull louislam/uptime-kuma:1
docker stop uptime-kuma
docker rm uptime-kuma
docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1

Conclusion

Now you have installed Uptime Kuma.
This tutorial contains content from https://github.com/louislam/uptime-kuma.

License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contributor's Certificate of Origin

By making a contribution to this project, I certify that:

  1. The contribution was created in whole or in part by me and I have the right to submit it under the license indicated in the file; or

  2. The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same license (unless I am permitted to submit under a different license), as indicated in the file; or

  3. The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.

  4. I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the license(s) involved.

Published 16/01/2021 by Zoey Löchner

Submit your tutorial

Get 60€ netcup vouchers for every published tutorial.