Article directory
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
- Monitor HTTP(s) / TCP / HTTP(s) Keywords / Ping / DNS Records / Push / Steam game server uptime.
- Fancy, reactive, fast UI/UX.
- Send notifications via Telegram, Discord, Gotify, Slack, Pushover, email (SMTP) and 70+ notification services.
- Provide agent support.
- Supports multiple languages.
- Ping Chart.
- 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.
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
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:
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,可以自行修改端口
Execute the following command in this directory: /root/dockertest/kuma to start the monitoring service:
docker-compose up -d
After the pull is completed, run docker ps to view the started containers:
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:
In this interface we can add websites to monitor:
Click Add in the upper left corner, configure the monitoring URL, and set the monitoring name:
Set up website exception notification:
Supports various notification functions. It is recommended to configure alarm functions such as email and Feishu notifications.
After the configuration is completed, the display is as follows:
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.
Open my Cpolar Webui address and log in:
http://192.168.1.237:9200/
Click Tunnel Management on the left dashboard - Create Tunnel
The configuration is as follows:
- 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:
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
Open this https address, which is the mapped public network address:
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.
The prompt for successful retention is as follows:
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
Modify the tunnel configuration information as follows:
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.
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.
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.