使用 Traefik 作为反向代理的 Immich 自托管 Docker 设置
这是我运行 Immich 作为自托管照片和视频备份解决方案的 Docker 和 Traefik 设置。它使用 Traefik 作为反向代理来处理 HTTPS 和路由。
有关 Traefik 设置,请参阅使用 Lets Encrypt Cloudflare DNS-01 & TLS-ALPN-01 & HTTP-01 挑战的简单 Traefik docker-compose 设置。
docker-compose.yml
services:
immich-server:
container_name: immich_server
image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
# extends:
# file: hwaccel.transcoding.yml
# service: cpu # 设置为 [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] 之一以启用加速转码
volumes:
- ./immich_photos:/usr/src/app/upload
- /etc/localtime:/etc/localtime:ro
env_file:
- .env
#ports:
# - 2283:2283
depends_on:
- redis
- database
restart: always
healthcheck:
disable: false
labels:
- "traefik.enable=true"
- "traefik.http.routers.immich-mydomain.rule=Host(`immich.mydomain.com`)"
- "traefik.http.routers.immich-mydomain.entrypoints=websecure"
- "traefik.http.routers.immich-mydomain.tls.certresolver=cloudflare-ec384"
- "traefik.http.routers.immich-mydomain.tls.domains[0].main=mydomain.com"
- "traefik.http.routers.immich-mydomain.tls.domains[0].sans=*.mydomain.com"
- "traefik.http.services.immich-mydomain.loadbalancer.server.port=2283"
immich-machine-learning:
container_name: immich_machine_learning
image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
# extends:
# file: hwaccel.ml.yml
# service: cpu # 设置为 [armnn, cuda, rocm, openvino, openvino-wsl, rknn] 之一以启用加速推理
#ports:
# - 3003:3003
volumes:
- ./model_cache:/cache
env_file:
- .env
restart: always
healthcheck:
disable: false
redis:
container_name: immich_redis
image: docker.io/valkey/valkey:8-bookworm@sha256:fec42f399876eb6faf9e008570597741c87ff7662a54185593e74b09ce83d177
healthcheck:
test: redis-cli ping || exit 1
restart: always
database:
container_name: immich_postgres
image: ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0
env_file:
- .env
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_DB: ${DB_DATABASE_NAME}
POSTGRES_INITDB_ARGS: '--data-checksums'
volumes:
- ./postgres_data:/var/lib/postgresql/data
ports:
- 5432:5432
shm_size: 128mb
restart: always环境文件(.env)
.env
# 你可以在 https://immich.app/docs/install/environment-variables 找到所有支持的环境变量的文档
# 要设置时区,请取消注释下一行并将 Etc/UTC 更改为此列表中的 TZ 标识符:https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
TZ=Europe/Berlin
# 要使用的 Immich 版本。你可以将其固定到特定版本,如 "v1.71.0"
IMMICH_VERSION=release
# postgres 的连接密钥。你应该将其更改为随机密码
# 请仅使用 `A-Za-z0-9` 字符,不要使用特殊字符或空格
DB_PASSWORD=chohgh5ufeeM1Boich2ieV5ighufie
# 此行以下的值无需更改
###################################################################################
DB_USERNAME=postgres
DB_DATABASE_NAME=immichCheck out similar posts by category:
Docker
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow