静看光阴荏苒
不管不顾不问不说也不念

Medama:开源轻量级网站统计(分析)系统

Medama介绍,摘自项目页面:

📊 Real-Time Analytics: Monitor website performance and user interactions instantly.

🔒 Privacy-Focused: Lightweight tracker (<1KB) without cookies, IP addresses, or additional identifiers, ensuring compliance with GDPR, PECR, and other regulations.

🧪 Easy To Integrate: OpenAPI-based server for effortless integration into personal or professional dashboards.

💼 Self-Hostable: Simple, single-binary setup with no external dependencies, capable of running on VMs with 256MB memory for most small websites.

我使用docker部署,先安装需要用到的软件:

apt -y update
apt -y install curl nginx python3-certbot-nginx
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh

准备目录新建compose文件:

mkdir -p /opt/medama && cd /opt/medama && nano docker-compose.yml

写入如下配置:

services:
  medama:
    image: ghcr.io/medama-io/medama:latest
    restart: unless-stopped
    environment:
      - LOGGER=pretty
    ports:
      - "8080:8080"
    volumes:
      - medama-data:/app/data

volumes:
  medama-data:

启动:

docker compose up -d

配置NGINX反向代理:

nano /etc/nginx/sites-available/medama

写入如下配置:

server {
    listen 80;
    listen [::]:80;
    server_name medama.example.com;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto "https";
        client_max_body_size 0;
    }
}

启用站点:

ln -s /etc/nginx/sites-available/medama /etc/nginx/sites-enabled/medama

签发TLS证书:

certbot --nginx --email imlala@example.com --agree-tos --no-eff-email

访问medama.example.com,默认的管理员账号:admin,密码:CHANGE_ME_ON_FIRST_LOGIN

点击添加新站点,填写要统计的网站域名:

然后将下面的统计代码复制粘贴到对应网站中:

<script defer src="https://medama.example.com/script.js"></script>

效果:

赞(2)
未经允许不得转载:荒岛 » Medama:开源轻量级网站统计(分析)系统
分享到: 更多 (0)

评论 2

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #1

    感谢教程,我还是喜欢matomo

    14个月前 (08-04) Google Chrome 121.0.0.0 Google Chrome 121.0.0.0 Windows 10 x64 Edition Windows 10 x64 Edition回复
  2. #2

    用它还不如umami

    1112个月前 (10-18) Microsoft Edge 129.0.0.0 Microsoft Edge 129.0.0.0 Windows 10 x64 Edition Windows 10 x64 Edition回复

分享创造快乐

广告合作资源投稿