文章

Umami的Docker部署

Umami嵌入Halo博客,统计用户流量数据

1.防火墙开放相关端口(默认为3000和5432),可选择容器端口映射

2.docker容器部署umami

---
version: '3'
services:
  umami:
    image: docker.umami.dev/umami-software/umami:postgresql-latest
    ports:
      - "3000:3000"
    environment:
      DATABASE_URL: postgresql://umami:umami@db:5432/umami # user:password
      DATABASE_TYPE: postgresql
      APP_SECRET: replace-me-with-a-random-string # openssl rand -base64 32
    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:/var/lib/postgresql/data
    restart: always   

3.申请域名

4.SSL,配置Https

5.开启反向代理,添加配置

    add_header Access-Control-Allow-Origin 'https://博客域名';
    add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
    add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
    add_header Content-Security-Policy 'frame-ancestors 博客域名';
    proxy_hide_header 'Access-Control-Allow-Origin';
    proxy_hide_header 'Content-Security-Policy';
    if ($request_method = 'OPTIONS') {
      return 204;
    }

6.嵌入博客

Umami站点地址:
# https://umami部署所用域名

站点地址:
# Website ID

共享链接:
# Share URL

License:  CC BY 4.0