Skip to content

Commit

Permalink
Merge pull request #156 from CuzImBisonratte/update-install-uptime-ku…
Browse files Browse the repository at this point in the history
…ma-standalone-tutorial

Update install uptime kuma standalone tutorial
  • Loading branch information
Christoph authored Jan 30, 2024
2 parents 50f5b7d + ebea716 commit 16d9e9f
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 107 deletions.
122 changes: 70 additions & 52 deletions community-tutorials/how-to-install-uptime-kuma/01-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@
title: Setup of Standalone Uptime Kuma on Ubuntu with a Reverse Proxy
description: Learn how to set up Uptime Kuma, a free and open source uptime monitor, on Ubuntu and use nginx as a reverse proxy to operate it securely.
level: beginner
updated_at: 2023-04-20
updated_at: 2023-11-28
slug: ubuntu-uptime-kuma-standalone-installation
author_name: Konstantin Protzen
author_url: https://github.com/cuzimbisonratte
author_image: https://github.com/cuzimbisonratte.png
author_bio:
tags: [linux, ubuntu, uptime, monitoring, kuma, nodejs, nginx, proxy, reverse-proxy]
tags:
[linux, ubuntu, uptime, monitoring, kuma, nodejs, nginx, proxy, reverse-proxy]
netcup_product_url: https://www.netcup.de/bestellen/produkt.php?produkt=2991
language: en
available_languages: [en, de]
---

# Introduction

This tutorial describes how to set up an Uptime Kuma instance on Ubuntu 20.04. Uptime Kuma is a free and open source uptime monitor. It is a self-hosted alternative to services like Uptime Robot or StatusCake. It is available as a Docker image, but this tutorial describes how to set up an instance without Docker (as a standalone).

This tool is very useful for getting notified when a service is down.

The time needed to follow this tutorial is approximately 10 - 20 minutes.

The tutorial was tested on Ubuntu 22.04 (April 2023).
The tutorial was tested on Ubuntu 22.04 (November 2023).

The tutorial uses the example ip `123.123.123.123`.
This hostname needs to be replaced by the name of your own server when you perform the steps described below.
Expand All @@ -30,7 +32,8 @@ We will also use the domain `example.com` in this tutorial. Replace it with your
We will not use the installation script provided by Uptime Kuma, because it is sometimes buggy.

# Requirements
For a 'small instance' (up to 20 monitored services) VPS 200 is sufficient.

For a 'small instance' (up to 20 monitored services) VPS 200 is sufficient.

I recommend setting up the instance on a VPS 200.
If you feel like the instance is slowing down, you can always update to a bigger server trough the CCP.
Expand All @@ -39,43 +42,50 @@ The server needs to have Ubuntu 20.04 and SSH already installed.

<hr>

You will also need a domain. A domain used in a webhosting package is sufficient. (You can still use it for your webhosting, because we will use a subdomain.)
You will also need a domain. A domain used in a webhosting package is sufficient. (You can still use it for your webhosting, because we will use a subdomain.)

# Step 1 - Finding out the IP of your server

# Step 1 - Finding out the IP of your server
1. Log in to the SCP (ServerControlPanel) under https://www.servercontrolpanel.de.
2. Click on the server you want to use.
3. If you are already on the "General" tab, you'll see a pane labeled "Network" in the bottom right corner.
4. Here you can find the IP of your server (under IPv4).
5. Write the IP of your server down.

# Step 2 - Configuring DNS

1. Log in to the CCP (CustomerControlPanel) under https://www.customercontrolpanel.de.
2. In the sidebar on the left, click on "Domains".
3. Find the domain you want to use and click on the magnifying glass symbol next to it.
4. In the new window, click on "DNS".
5. Scroll down until there are empty fields.
6. In the first field, write your subdomain name (I recommend using "status").
6. In the first field, write your subdomain name (I recommend using "status").
7. In the dropdown menu, select `A`.
8. In the last field, enter the IP of your server (from Step 1).
9. Click on "Save DNS records".

# Step 3 - Preparing the server

First you need to log in to your server via SSH, then follow these steps:

1. Enter `sudo -s` to get root privileges.
2. If asked for your password, enter it and press `Enter`.
3. Now enter `apt update -y && apt upgrade -y` to update the server.
4. If a pink window appears, press `Enter` once to continue.
5. Enter `curl https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh && bash /tmp/nodesource_setup.sh` to install NodeJS 16.
6. Enter `apt install nodejs curl nginx git -y` to install all the required software.
7. If a pink window appears, press `Enter` once to continue.
8. Enter `npm install npm -g` to update npm.
9. If a pink window appears, press `Enter` once to continue.
10. Enter `npm install pm2 -g && pm2 completion install` to install pm2 and its autocompletion.
11. Enter `exit` and press `Enter` to leave root privileges.

# Step 4 - Installing Uptime Kuma
Enter the following command to install Uptime Kuma:
5. Enter `apt install curl nginx git -y` to install all the required software.
6. Enter `adduser uptimekuma --gecos "" --disabled-password && su uptimekuma` to create a new user and switch to it.

# Step 4 - Installing Node.js

1. Enter `cd && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash` to install NVM.
2. Enter `source ~/.bashrc` to install all the required software.
3. Enter `nvm install 18 && nvm use 18` to install and activate NodeJS 18.
4. Enter `npm install npm pm2 -g && pm2 completion install` to install pm2 and its auto completion.

# Step 5 - Installing Uptime Kuma

Enter the following command to install Uptime Kuma:

1. Enter `git clone https://github.com/louislam/uptime-kuma.git` to clone the repository.
2. Change directory by executing `cd uptime-kuma`.
3. Enter `npm run setup` to install all dependencies.
Expand All @@ -84,16 +94,17 @@ Enter the following command to install Uptime Kuma:
Once you see "Listening on 3001" in the terminal, go to your IP on Port 3001 (e.g. `123.123.123.123:3001`) in your browser.
If you see the Uptime Kuma setup screen, you have successfully installed Uptime Kuma. Please stop the server by pressing `Ctrl + C` in the terminal once. You have to wait a little while until the server stops.

# Step 5 - Reverse Proxy with nginx
# Step 6 - Reverse Proxy with nginx

1. Enter `sudo -s` to get root privileges.
2. If asked for your password, enter it and press `Enter`.
3. Enter `nano /etc/nginx/sites-available/uptime-kuma` to create a new nginx config file.
3. Enter `nano /etc/nginx/sites-available/uptimekuma` to create a new nginx config file.
4. Paste the following code into the file:

```nginx
server {
listen 80;
# Remove '#' in the next line to enable IPv6
# listen [::]:80;
listen [::]:80;
server_name sub.domain.com;
location / {
proxy_pass http://localhost:3001;
Expand All @@ -104,18 +115,21 @@ server {
}
}
```

5. Replace `sub.domain.com` with your subdomain (e.g. `status.example.com`).
6. Exit the file by pressing `Ctrl + X` and then `Y` and then `Enter`.
7. Enter `ln -s /etc/nginx/sites-available/uptime-kuma /etc/nginx/sites-enabled/uptime-kuma` to enable the config file.
7. Enter `ln -s /etc/nginx/sites-available/uptimekuma /etc/nginx/sites-enabled/uptimekuma` to enable the config file.
8. Enter `nginx -t` to test the config file.
9. If you see `test is successful`, you can reload nginx by entering `systemctl reload nginx`.

# Step 6 - Setting up Uptime Kuma to start on boot
# Step 7 - Setting up Uptime Kuma to start on boot

We want to start Uptime Kuma automatically when the server starts.
This is useful when the server reboots, as we cannot monitor the server running Kuma. When it is restarted, Kuma will also be restarted.

1. Enter `nano /etc/systemd/system/uptime-kuma.service` to create a new systemd service file.
1. Enter `nano /etc/systemd/system/uptimekuma.service` to create a new systemd service file.
2. Paste the following code into the file:

```systemd
[Unit]
Description=Uptime-Kuma - A free and open source uptime monitoring solution
Expand All @@ -124,57 +138,60 @@ After=network.target
[Service]
Type=simple
User=[REPLACE_WITH_USERNAME]
WorkingDirectory=/home/[REPLACE_WITH_USERNAME]/uptime-kuma
ExecStart=/usr/bin/npm run start-server
User=uptimekuma
WorkingDirectory=/home/uptimekuma/uptime-kuma
ExecStart=/home/uptimekuma/.nvm/versions/node/v18.18.2/bin/node /home/uptimekuma/uptime-kuma/server/server.js
Restart=on-failure
[Install]
WantedBy=multi-user.target
```
3. Replace `[REPLACE_WITH_USERNAME]` with the user under which you want to run Uptime Kuma (we don't want to run it as root, so please run it as your SSH login user or create a new user).
4. Exit the file by pressing `Ctrl + X` and then `Y` and then `Enter`.
5. Enter `systemctl daemon-reload` to reload the systemd daemon.
6. Enter `systemctl enable uptime-kuma` to enable the service.
7. Enter `systemctl start uptime-kuma` to start the service.

# Step 7 - Setting up HTTPS
3. Exit the file by pressing `Ctrl + X` and then `Y` and then `Enter`.
4. Enter `systemctl daemon-reload` to reload the systemd daemon.
5. Enter `systemctl enable uptime-kuma` to enable the service.
6. Enter `systemctl start uptime-kuma` to start the service.

# Step 8 - Setting up HTTPS

1. Enter `snap install --classic certbot` to install CertBot.
2. Enter `certbot --nginx` to start the CertBot setup.
3. I recommend using these settings:
1. Enter your email address.
2. Yes (Terms of Service)
3. No (Advertisement)
4. Press `Enter` to select the only option (your domain).
5. This process can take a while, so please be patient.

# Step 8 - Setting up the Firewall
1. Enter your email address.
2. Yes (Terms of Service)
3. No (Advertisement)
4. Press `Enter` to select the only option (your domain).
5. This process can take a while, so please be patient.

# Step 9 - Setting up the Firewall

We need a firewall to protect our server from unwanted connections.

We will use `ufw` (Uncomplicated Firewall) to set up the firewall, because it is easy to use and configure and is also pre-installed on Ubuntu.

1. Enter `ufw allow ssh` to allow SSH connections.
2. Enter `ufw allow http` to allow HTTP connections.
3. Enter `ufw allow https` to allow HTTPS connections.
4. Enter `ufw enable` to enable the firewall.
5. Press `Y` and then `Enter` to confirm.
1. Enter `ufw allow ssh && ufw allow http && ufw allow https && ufw enable` to setup the firewall and then enable it.
2. Press `Y` and then `Enter` to confirm.

# Step 10 - Setting up Uptime Kuma

# Step 9 - Setting up Uptime Kuma
1. Open your browser and go to your subdomain (e.g. `https://status.example.com`).
2. You should see the Uptime Kuma setup screen.
3. Enter your username and password, also choose the right language. The username is case sensitive!
4. Click on "Create".
5. In the top right corner, click on the dropdown menu and select "Settings".
6. In the "General" tab under "Primary Base URL", click on "Auto Get" so that the URL is automatically set.

If this works, you should now restart the server and check if everything starts as it should. To do this, execute `shutdown -r now`. After executing the command, you can close the SSH connection.
If this works, you should now restart the server and check if everything starts automatically as it should. To do this, execute `shutdown -r now`. After executing the command, you can close the SSH connection.

# Conclusion
Now you have successfully installed Uptime Kuma and set it up to start on boot.

Now you have successfully installed Uptime Kuma and set it up to start on boot.

From now on your Kuma instance will be available under your subdomain (e.g. `https://status.example.com`).

If you want to update Uptime-Kuma, you can follow the tutorial [Update Your Uptime Kuma Instance](https://community.netcup.com/en/tutorials/update-uptime-kuma) folgen.
Wenn du Alerts einrichten möchtest, kannst du dem Tutorial [Setup of Uptime Kuma Real-Time Alerts](https://community.netcup.com/en/tutorials/uptime-kuma-notification-setup) folgen.

Thank you for using this tutorial!

# Licence
Expand All @@ -188,12 +205,13 @@ The above copyright notice and this permission notice shall be included in all c
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 licence indicated in the file; or
1. The contribution was created in whole or in part by me and I have the right to submit it under the licence 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 licence and I have the right under that licence 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 licence), as 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 licence and I have the right under that licence 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 licence), 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.
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 licence(s) involved.
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 licence(s) involved.
Loading

0 comments on commit 16d9e9f

Please sign in to comment.