一、安装docker
1.安装前提:
yum -y install gcc gcc-c++
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo             #国外使用
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo    #国内使用
yum makecache fast

2.安装和启动
yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
systemctl start docker
systemctl enable docker
ps -ef|grep docker

3.安装docker-compose
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose -v
二、安装Umami网站统计工具
1、mkdir /data/umami && cd /data/umami

2、vi docker-compose.yml
注意:国内可以将ghcr.io改为docker.umami.dev
---
version: '3'
services:
  umami:
    image: ghcr.io/umami-software/umami:postgresql-latest
    ports:
      - "3000:3000"
    environment:
      DATABASE_URL: postgresql://umami:umami@db:5432/umami
      DATABASE_TYPE: postgresql
      APP_SECRET: replace-me-with-a-random-string
      TRACKER_SCRIPT_NAME: random-string.js
    depends_on:
      - db
    restart: always
  db:
    image: postgres:15-alpine
    environment:
      POSTGRES_DB: umami
      POSTGRES_USER: umami
      POSTGRES_PASSWORD: umami
    volumes:
      - ./sql/schema.postgresql.sql:/docker-entrypoint-initdb.d/schema.postgresql.sql:ro
      - umami-db-data:/data/postgresql/data
    restart: always
volumes:
  umami-db-data:

3、启用 Docker 容器:
docker compose up -d

此时,打开 http://server_ip:3000即可登录 Umami 开始使用了。
默认账号:admin
默认密码:umami
三、配置nginx反向代理
server {
    listen 80;
    server_name tongji.xxxx.com;
    access_log  /data/log/nginx/access_tongji.log;

    location /  {
        proxy_pass http://127.0.0.1:3000;
        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 $scheme;
        proxy_set_header REMOTE-HOST $remote_addr;
        add_header X-Cache $upstream_cache_status;
        # 缓存
        add_header Cache-Control no-cache;
        expires 12h;
    }

}
    #限制后台登录设置
        location /login {
        allow 127.0.0.1;
        allow 本地公网ip;
        #add dynamic
        deny all;
    proxy_pass http://127.0.0.1:3000;
        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 $scheme;
        proxy_set_header REMOTE-HOST $remote_addr;
        add_header X-Cache $upstream_cache_status;
        # 缓存
        add_header Cache-Control no-cache;
        expires 12h;
    }

然后reload nginx,可以加cdn
不要缓存 .jpg;.png;.js;.css,尤其不要缓存js。