Files
admin/.wiki/concepts/minio-imgproxy-on-vds.md
vitya e17e8eb1c3 mssql+minio vds migration done — IIS snolla cutover live
- mssql-vds-migration 🟢: Express 2022 Linux на mssql.kzntsv.site:1433,
  5 DBs restored (schema 2019→2022 auto-upgrade), 8 prod hosts 200 OK
- minio-imgproxy-vds-migration 🟡: stack live, 3 GiB / 19324 obj mirrored
  (2020→2025 upgrade via S3 API), DNS swap imgproxy.kzntsv.site pending
- iis-cutover-to-vds-services 🟡: 1 web.config edit catch-all для 11 hosts;
  MinIO leg pending DNS swap (URLs уже через imgproxy.kzntsv.site domain)
- 3 wiki concepts: mssql-on-vds, minio-imgproxy-on-vds, index updated

Findings: (1) server logins НЕ переезжают в .bak — orphan fix manual,
(2) traefik recreate-not-restart для port mapping change,
(3) PowerShell не вызывает pass bash-script (NULL pw → misleading auth fail),
(4) mc 2025 не auto-creates target buckets, (5) non-ASCII filename silent
skip в mc mirror — verify по count+size обязательно.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 09:55:17 +03:00

99 lines
5.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: MinIO + imgproxy stack on vds-kzntsv
status: live (data-layer); DNS swap pending для imgproxy.kzntsv.site
tags: [vds, minio, imgproxy, migration, ops]
related: [[vds-kzntsv]], [[recovery-architecture-snapshot]], [[mssql-on-vds]]
---
# MinIO + imgproxy on vds-kzntsv
Запущен 2026-05-22 как часть `minio-imgproxy-vds-migration`. Заодно **upgrade MinIO** `RELEASE.2020-07-13` (5 лет, CVE-куча) → `RELEASE.2025-09-07`.
## Architecture
```
CMS templates (URL pattern: imgproxy.kzntsv.site/<sig>/.../plain/s3://<bucket>/<path>)
→ traefik (windows-host) [пока, до DNS swap]
→ imgproxy-nginx (windows-host) [пока]
→ imgproxy (windows-host) [пока]
→ MinIO localhost:9000 (windows-host) [пока]
После DNS swap imgproxy.kzntsv.site → 89.253.255.94 (VDS):
→ VDS traefik (HTTPS, LE cert)
→ imgproxy-nginx (VDS, nginx:alpine, 10 GB cache)
→ imgproxy (VDS, darthsim/imgproxy:latest)
→ minio (VDS, RELEASE.2025-09-07, internal docker DNS через proxy network)
```
Stack: `/opt/stacks/storage/minio-imgproxy/{docker-compose.yml,.env,data,nginx.conf,nginx-cache}`. Все 3 контейнера в `proxy` network — service-name DNS работает.
**Traefik routes (live):**
- `minio.vds.kzntsv.site` → minio:9000 (S3 API)
- `minio-console.vds.kzntsv.site` → minio:9001 (web UI)
- `imgproxy.vds.kzntsv.site` → imgproxy-nginx:80 (test endpoint pre-cutover)
После DNS swap имя `imgproxy.kzntsv.site` (без `.vds.`) добавить в traefik label imgproxy-nginx сервиса.
## Migration recipe
```bash
# 1. pass insert (local) — preserve original IMGPROXY_KEY/SALT, reuse MinIO creds
pass insert -m minio-vds/full-env <<EOF
MINIO_ROOT_USER=<same-as-source>
MINIO_ROOT_PASSWORD=<same-as-source>
IMGPROXY_KEY=<same-as-source-128hex>
IMGPROXY_SALT=<same-as-source-128hex>
EOF
# 2. VDS: create dir + scp nginx.conf + write .env from pass + write compose
ssh vitya@vds 'sudo mkdir -p /opt/stacks/storage/minio-imgproxy/{data,nginx-cache}
sudo chown -R vitya:vitya /opt/stacks/storage'
scp <source>/nginx.conf vitya@vds:/opt/stacks/storage/minio-imgproxy/
pass show minio-vds/full-env | ssh vitya@vds 'cat > /opt/stacks/storage/minio-imgproxy/.env
chmod 600 .env'
# 3. docker compose up -d (image pull + start all 3)
# 4. Local mc setup + bucket prep
mc alias set old http://localhost:9000 <creds>
mc alias set new https://minio.vds.kzntsv.site <creds> --insecure
for b in $(mc ls old | awk '{print $NF}' | tr -d /); do
mc mb --ignore-existing new/$b --insecure # mc 2025 не auto-creates на mirror
done
# 5. Mirror (background, ~1 час на 3 GB при 600 KiB/s)
mc mirror --preserve --quiet --overwrite old new --insecure
# 6. Verify per-bucket (size + object count)
for b in $(mc ls old | awk '{print $NF}' | tr -d /); do
echo "[$b]"; mc du old/$b; mc du new/$b --insecure
done
```
## Gotchas
1. **MinIO upgrade 5-летний gap WORKS via mc mirror** — старый FS backend (2020) → новый erasure-coded single-drive (2025) совместим через S3 API copy. `mc mirror` reads через S3 API, не сырое filesystem. Бинарный bind-mount свопнуть НЕЛЬЗЯ — формат `xl.meta` разный, новый MinIO не поднимется на старых dirs.
2. **mc 2025 НЕ auto-creates target buckets** — old mc (<2023?) делало неявно. Симптом: `Failed to perform mirroring The specified bucket does not exist`. Fix: `mc mb --ignore-existing new/<b>` для каждого bucket заранее.
3. **Non-ASCII filenames + slow uplink → partial mirror failure**: один файл `Albrecht Dürer ...tif` (30 MiB) в `imgproxytest` bucket не доехал с первого `mc mirror` exit=0 — silent skip без error. Retry того же `mc mirror` подтащил. Recommendation: всегда verify по object count + size после mirror, не doверять exit code.
4. **IMGPROXY_KEY + IMGPROXY_SALT preserve обязательно** — это HMAC signing для URLs. Если поменять, все pre-existing CMS image URLs (signed ссылки в шаблонах + кешированные в admin) ломаются. Reuse same values из source.
5. **MinIO root creds vs AWS-style**: source использует MINIO_ACCESS_KEY/MINIO_SECRET_KEY (deprecated env vars), новый MinIO — MINIO_ROOT_USER/MINIO_ROOT_PASSWORD. Reuse same values (no rotation в этой миграции) → CMS+imgproxy credentials не меняются. Rotation — отдельная hardening-таска.
## DNS swap (pending — user action)
`imgproxy.kzntsv.site` сейчас A-record на windows-host IP. Чтобы переключить картинки на VDS:
1. REGRU: `imgproxy.kzntsv.site` A → 89.253.255.94 (TTL 300s).
2. Дождаться propagate (`Resolve-DnsName imgproxy.kzntsv.site`).
3. В `/opt/stacks/storage/minio-imgproxy/docker-compose.yml` для service `imgproxy-nginx` добавить router rule `imgproxy.kzntsv.site` рядом с existing `imgproxy.vds.kzntsv.site`.
4. `docker compose up -d` (apply labels).
5. LE cert auto-issued.
## Rollback
```bash
# On VDS
cd /opt/stacks/storage/minio-imgproxy && sudo docker compose down -v
# Source windows-host MinIO + imgproxy + imgproxy-nginx должны быть still running (48ч uptime acceptance).
# Если уже decommissioned — docker start minio imgproxy imgproxy-nginx.
# Snapshot insurance: tar archive bind-mount source data preserved отдельно (acceptance step 3).
```