Build the open source operation and maintenance monitoring tool Uptime Kuma in 5 minutes and realize remote access without public network IP


img

If you're like me and host multiple websites on your server and don't have enough time to manually check the online status of each website, then when problems arise, you may not be notified in time to handle them. Therefore, it is necessary to build an online monitoring service that can remind you when the status is abnormal so that you can deal with the problem in time and ensure the stability and availability of the website.

There are many monitoring services, and I finally chose Uptime Kuma because Uptime Kuma is open source and free, and currently has 43.1k stars on Github! It is very convenient to set up and takes up low system resources.

The main function

  1. Monitor HTTP(s) / TCP / HTTP(s) Keywords / Ping / DNS Records / Push / Steam game server uptime.
  2. Fancy, reactive, fast UI/UX.
  3. Send notifications via Telegram, Discord, Gotify, Slack, Pushover, email (SMTP) and 70+ notification services.
  4. Provide agent support.
  5. Supports multiple languages.
  6. Ping Chart.
  7. Certificate Info.

The following describes how to use Docker in Linux to deploy Uptime Kuma with one click and map this service to public network access.

1. Preparation

The environment of this tutorial is: Centos7. Any system that can run Docker can use this tutorial to install it.

image-20231219171530642

This tutorial uses Docker to deploy services. For details on how to install Docker, see:

Install Docker Engine on CentOS | Docker Docs

Use the following command to test whether Docker is working properly:

docker run hello-world

image-20231219172107787

2. Docker deploys Uptime Kuma

按照顺序执行如下命令,路径位置可自行修改
mkdir -p /root/dockertest/kuma  # 新建安装文件夹

cd /root/dockertest/kuma   # 切换至安装路径

touch docker-compose.yml  # 创建docker配置文件

The execution results are as follows:

image-20231220180234239

Edit the yml configuration file we just created:

vim docker-compose.yml

Write the following information:

version: '3.3'

services:
  uptime-kuma:
    image: louislam/uptime-kuma
    container_name: uptime-kuma
    volumes:
      - /root/dockertest/kuma/data:/app/data
    ports:
      - 5702:3001	# 我设置的访问端口号为5702,可以自行修改端口

image-20231220180901400

Execute the following command in this directory: /root/dockertest/kuma to start the monitoring service:

docker-compose up -d

image-20231220165544383

After the pull is completed, run docker ps to view the started containers:

image-20231220165622832

At this time, our browser opens the server IP:5702 , and my address is:

http://192.168.1.237:5702/

Enter the username and password to enter the login interface:

image-20231220170105283

In this interface we can add websites to monitor:

image-20231220170128942

Click Add in the upper left corner, configure the monitoring URL, and set the monitoring name:

image-20231220170451461

Set up website exception notification:

image-20231220171825780

Supports various notification functions. It is recommended to configure alarm functions such as email and Feishu notifications.

image-20231220171851867

After the configuration is completed, the display is as follows:

image-20231220171938537

3. Implement public network viewing website monitoring

Above we used Docker to deploy the website monitoring service on the local server, which can be accessed locally. However, once you leave the local area and need to check the website status and configure monitoring alarms, it does not work.

At this time, we need to install and use the intranet penetration tool to map the local service to the public network, so that we can publish it to the public network for remote access without registering a domain name and purchasing a cloud server!

I installed free unlimited traffic Cpolar on the server. The specific installation method is as follows:

cpolar official website address: https://www.cpolar.com

  • Use one-click script installation command
curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash
  • Add services to the system
sudo systemctl enable cpolar
  • Start cpolar service
sudo systemctl start cpolar

After cpolar is successfully installed, access Linux port 9200 on an external browser: [http://LAN ip:9200]. Log in using your cpolar account. After logging in, you can see the cpolar web configuration interface, which is connected to the web management interface. Just configure it.

image-20230831171159175

Open my Cpolar Webui address and log in:

http://192.168.1.237:9200/

Click Tunnel Management on the left dashboard - Create Tunnel

image-20231219155830455

image-20231220172059029

The configuration is as follows:

image-20231220172152263

  • Tunnel name: You can customize the name. Be careful not to duplicate the existing tunnel name.
  • Protocol: Select http
  • Local address: 5702 (fill in the custom modified port number)
  • Domain name type: Choose a random domain name for free
  • Region: Select China Top

Click创建

When the tunnel becomes active, it is created successfully:

image-20231220172426684

After the tunnel is successfully created, click the status on the left - online tunnel list to view the generated public network access address. There are two access methods, one is http and https

image-20231220172407611

image-20231220172741417

Open this https address, which is the mapped public network address:

image-20231220173642875

image-20231220173705897

summary

For a better demonstration, we used the tunnel generated by cpolar in the aforementioned process, and its public network address was randomly generated.

The advantage of this random address is that it is established quickly and can be used immediately. However, its disadvantage is that the URL is generated by random characters and is not easy to remember (for example: 3ad5da5.r10.cpolar.top). In addition, this address will change randomly within 24 hours, making it more suitable for temporary use.

I usually use a fixed second-level subdomain name because I hope it is a fixed and easy-to-remember public network address, which is more conducive to long-term monitoring services (for example: crm.cpolar.cn), which is more formal and facilitates communication and collaboration.

4. Use a fixed public network address to access the locally deployed monitoring service

Log in to the cpolar official website , click Reserve on the left, select to reserve the second-level subdomain name, set a second-level subdomain name, click Reserve, and copy the reserved second-level subdomain name after the reservation is successful.

image-20231220173942500

The prompt for successful retention is as follows:

image-20231220174005682

Return to log in to http://192.168.1.237:9200 Cpolar Webui management interface, click Tunnel Management - Tunnel List on the left dashboard, find the tunnel you want to configure, and click Edit

image-20231220173745280

Modify the tunnel configuration information as follows:

image-20231220174417628

Modify the tunnel information and configure the successfully reserved second-level subdomain name into the tunnel.

  • Domain name type: Select a second-level subdomain name
  • Sub Domain: Fill in the successfully reserved second-level subdomain name
  • Region: The region selected when you choose to reserve a domain name

Click 更新(note, click once to update, no need to submit again)

After the update is completed, open the online tunnel list. At this time, you can see that the public network address has changed and the address name has become a fixed second-level subdomain name.

image-20231220174520998

Finally, we use a fixed public network address to access, and we can see that the access is successful. In this way, a fixed and permanent public network address is set.

image-20231220174602525

At this point, we have implemented the deployment of website monitoring services using local servers and configured fixed public network address access, so that we can view website monitoring anytime and anywhere without renting a cloud server.

Guess you like

Origin blog.csdn.net/qq_48652579/article/details/135145397