VPS 4: Deploying a real time stats dashboard
Posted on January 31, 2025 • 2 minutes • 294 words • Other languages: Español
This is the fourth part of my VPS blog series .
Glances With Docker Compose
It’s time to deploy our first project: a real-time server stats dashboard. We’ll use Glances , a lightweight Python-based tool.
-
Create a new project: Let’s call it
vps-stats
. By default, it will be in anEnvironment: Production
. -
Add resource: Choose Docker Compose.
-
Paste the glances YAML : You need to adapt it a little bit for Coolify. Here’s the final working version:
version: '3' services: monitoring: image: nicolargo/glances:latest restart: always pid: host volumes: - /var/run/docker.sock:/var/run/docker.sock - /etc/os-release:/etc/os-release:ro environment: - "GLANCES_OPT=-w"
-
Configure domain and deploy:
stats.yourdomain.com:61208
Once live, visit stats.yourdomain.com
to see your dashboard
Secure With Caddy Basic Auth
Why?
- The dashboard exposes server metrics that may or may not be sensitive but shouldn’t be public.
- It is a nice exercise.
Generate hashed password
Caddy has a built-in command caddy hash-password
caddy hash-password
[-p, --plaintext <password>]
[-a, --algorithm <name>]
If for any reason you have Caddy installed in your machine, you can run it there. I don’t have Caddy on mine, but the VPS has Docker installed on it, so we can:
- Log into the VPS:
ssh user-with-sudo@yourdomain.com
- Spin up a Docker container:
sudo docker run --rm caddy caddy hash-password -p "yoursupersecretpassword"
- Copy the bcrypt hash output (starts with
$2b$
). - Logout.
Add to the service docker-compose.yml the caddy label
Now it should look something like this:
version: '3'
services:
monitoring:
image: 'nicolargo/glances:latest'
restart: always
pid: host
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
- '/etc/os-release:/etc/os-release:ro'
environment:
- GLANCES_OPT=-w
labels:
- 'caddy_0.basicauth.0_YOURUSERHERE=YOURHASHEDPASSWORDHERE'
Restart the service and visit stats.yourdomain.com
. You should now see an auth prompt.