fix(traefik-maljarka-502-bug): diagnosed — root cause CMS-side, не traefik
Bisect через X-Forwarded headers: IIS+CMS возвращает 502 specifically для Host: maljarka.tandemmebel.ru + X-Forwarded-Proto: https. Без XFP=https → 200. URL Rewrite rule из cms-port-leak-fix ставит HTTPS=on/SERVER_PORT=443 → CMS код для этого hostname падает в HTTPS-context. Same class как emspb /admin/assets 500 NullRef, rimiz 404 — pre-existing CMS issues. Side finding: traefik file-watch broken под Docker Desktop Windows (WSL2 9p не пропускает inotify). Rename .yml → .disabled оставался без эффекта 38min после изменения; только docker restart traefik подхватил. Это значит iis-traefik-dead-routes-cleanup был фантомным до сегодняшнего restart 07:42 UTC. 2 новых wiki concepts: traefik-file-watch-wsl2-broken (workarounds) + cms-maljarka-https-mode-crash (3 workarounds + 5 investigation places). Новая follow-up ⚪ cms-maljarka-https-mode-bug-fix. Final smoke post-restart: 7 live hosts ✅ Microsoft-IIS/10.0 без regression, 2 dead routes (sestech, ics-artmaterials) → 404 (cleanup теперь real). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
102
cms-maljarka-https-mode-crash.md
Normal file
102
cms-maljarka-https-mode-crash.md
Normal file
@@ -0,0 +1,102 @@
|
||||
---
|
||||
title: CMS 502 при HTTPS-mode для конкретного hostname (maljarka.tandemmebel.ru)
|
||||
type: concept
|
||||
tags: [cms, iis, gotcha, url-rewrite, https]
|
||||
sources: []
|
||||
updated: 2026-05-21
|
||||
---
|
||||
|
||||
# CMS 502 при HTTPS-mode для maljarka.tandemmebel.ru
|
||||
|
||||
CMS код (или CMS DB config) для `maljarka.tandemmebel.ru` падает когда IIS request попадает с включённым HTTPS-context (`HTTPS=on`/`SERVER_PORT=443`). Тот же hostname работает (200 OK) когда request интерпретируется как plain HTTP. Другие cms hosts (`tandemmebel.ru`, `emspb.ru`, `pilorama98.ru` и т.д.) работают нормально в HTTPS-mode.
|
||||
|
||||
## Симптом
|
||||
|
||||
Через traefik HTTPS chain:
|
||||
```
|
||||
GET https://maljarka.tandemmebel.ru/ → 502 Bad Gateway
|
||||
```
|
||||
|
||||
## Bisect-trace
|
||||
|
||||
| Direct backend request (внутри traefik container) | Headers | Result |
|
||||
|---|---|---|
|
||||
| `wget http://host.docker.internal:8089/ -H 'Host: maljarka.tandemmebel.ru'` | base | **200 OK** (43730 bytes, "Малярка от Тандеммебель") |
|
||||
| same + `X-Forwarded-For: 1.2.3.4` | XFF only | **200 OK** |
|
||||
| same + `X-Forwarded-Proto: https` | XFP=https | **502** ← триггер |
|
||||
| same + ALL X-Forwarded-* | full | **502** |
|
||||
| `Host: tandemmebel.ru` + XFP=https | sibling control | 301 (correct) |
|
||||
|
||||
`X-Forwarded-Proto: https` — единственная переменная которая триггерит 502 для maljarka.tandemmebel.ru.
|
||||
|
||||
## Mechanism
|
||||
|
||||
После [[cms-server-port-leak-fix]] в `C:\sites\snolla\Web.config` добавлен URL Rewrite rule:
|
||||
|
||||
```xml
|
||||
<rule name="ForwardedProto-HTTPS" stopProcessing="false">
|
||||
<match url=".*" />
|
||||
<conditions>
|
||||
<add input="{HTTP_X_FORWARDED_PROTO}" pattern="^https$" />
|
||||
</conditions>
|
||||
<action type="None" />
|
||||
<serverVariables>
|
||||
<set name="HTTPS" value="on" />
|
||||
<set name="SERVER_PORT" value="443" />
|
||||
<set name="SERVER_PORT_SECURE" value="1" />
|
||||
</serverVariables>
|
||||
</rule>
|
||||
```
|
||||
|
||||
Когда traefik проксит request через HTTPS entrypoint, он добавляет `X-Forwarded-Proto: https` (стандартное поведение). IIS URL Rewrite rule срабатывает → ставит `HTTPS=on` / `SERVER_PORT=443`. CMS код (`MoreThenCms.Web`) видит request как HTTPS.
|
||||
|
||||
Для большинства hostname'ов CMS строит URLs корректно в HTTPS-context. Для `maljarka.tandemmebel.ru` — что-то падает (NullRef в URL builder, missing config, redirect loop, etc.) → ASP.NET unhandled exception → IIS возвращает 502.
|
||||
|
||||
## Where to investigate (next session)
|
||||
|
||||
1. **IIS Logs** — `C:\inetpub\logs\LogFiles\W3SVC*\` для site `snolla` — найти request с `Host: maljarka.tandemmebel.ru` + XFP=https → status code + sub-status.
|
||||
2. **ASP.NET Event Log** — `eventvwr.msc` → Application log → ASP.NET 4.0 errors с stack trace.
|
||||
3. **CMS DB** — table с per-host config (если есть field "https URL" / "base URL"); может для maljarka.tandemmebel.ru эта запись `NULL`/empty.
|
||||
4. **CMS source** — grep по `siteRoot`, `BaseUrl`, `HttpsUrl` в коде CMS; искать где условие `IsSecureConnection` или `Request.IsHttps` ветвит логику.
|
||||
5. **`Url.SiteRoot()`** — уже паттерн из [[cms-server-port-leak-fix]]; возможно тут другой helper падает specifically на этом host.
|
||||
|
||||
## Workarounds
|
||||
|
||||
### Workaround A: Strip X-Forwarded-Proto для maljarka в traefik (быстро, но скрывает CMS bug)
|
||||
|
||||
В `maljarka.yml` добавить middleware:
|
||||
```yaml
|
||||
http:
|
||||
routers:
|
||||
maljarka:
|
||||
...
|
||||
middlewares: [maljarka-strip-xfp]
|
||||
middlewares:
|
||||
maljarka-strip-xfp:
|
||||
headers:
|
||||
customRequestHeaders:
|
||||
X-Forwarded-Proto: ""
|
||||
```
|
||||
|
||||
Side effect: maljarka страница может содержать `http://...` asset links вместо `https://...` — mixed content warnings в браузере.
|
||||
|
||||
### Workaround B: Per-host bypass в URL Rewrite rule
|
||||
|
||||
В `C:\sites\snolla\Web.config` обновить rule:
|
||||
```xml
|
||||
<conditions>
|
||||
<add input="{HTTP_X_FORWARDED_PROTO}" pattern="^https$" />
|
||||
<add input="{HTTP_HOST}" pattern="^maljarka\.tandemmebel\.ru$" negate="true" />
|
||||
</conditions>
|
||||
```
|
||||
|
||||
Workaround C: hot-fix DB / Web.config с правильным базовым URL для maljarka.tandemmebel.ru (нужно исследование CMS).
|
||||
|
||||
## Применено
|
||||
|
||||
Не применено. Diagnosed only — fix отложен до CMS code investigation. Side-finding из [[traefik-maljarka-502-bug]].
|
||||
|
||||
## Ссылки
|
||||
|
||||
- URL Rewrite rule origin: [[cms-server-port-leak-fix]]
|
||||
- Other CMS-side 5xx bugs (паттерн): [[cms-admin-assets-root-folder-seed]] (другой NullRef), `emspb /admin/assets 500` (snapshot open issue #8).
|
||||
68
traefik-file-watch-wsl2-broken.md
Normal file
68
traefik-file-watch-wsl2-broken.md
Normal file
@@ -0,0 +1,68 @@
|
||||
---
|
||||
title: Traefik file-watch broken under Docker Desktop Windows (WSL2 9p mount)
|
||||
type: concept
|
||||
tags: [traefik, docker-desktop, windows, gotcha, wsl2]
|
||||
sources: []
|
||||
updated: 2026-05-21
|
||||
---
|
||||
|
||||
# Traefik file-watch broken под Docker Desktop Windows
|
||||
|
||||
Traefik file provider's `watch: true` **не работает** для bind mounts из Windows host через Docker Desktop WSL2 9p (виртуальная файловая система). Изменения на disk **не доходят** до traefik. Config остаётся frozen на startup state до явного `docker restart traefik`.
|
||||
|
||||
## Симптомы
|
||||
|
||||
1. Rename `.yml → .yml.disabled` — route ОСТАЁТСЯ active в traefik runtime, продолжает отвечать.
|
||||
2. Edit content of `.yml` — изменения не подхватываются, runtime использует старый snapshot.
|
||||
3. New `.yml` файл в `/custom/` — игнорируется, route не добавляется.
|
||||
4. `touch` обновление mtime — нет reload.
|
||||
5. В logs (`--log.level=DEBUG`) — никаких "Configuration reloaded" сообщений.
|
||||
|
||||
## Root cause
|
||||
|
||||
Docker Desktop на Windows монтирует bind volumes через WSL2 9p protocol (`/run/desktop/mnt/host/c/...`). 9p **не пропагирует inotify events** — fsnotify watchers внутри контейнера не получают уведомлений об изменениях. Traefik file-watcher использует `fsnotify` → молчит.
|
||||
|
||||
Это известная архитектурная проблема Docker Desktop Windows. Linux native Docker, Docker on macOS (через osxfs/virtiofs новый) — работают по-разному.
|
||||
|
||||
## Подтверждение
|
||||
|
||||
```powershell
|
||||
# 1. Mount bind path inside traefik
|
||||
docker inspect traefik --format '{{range .Mounts}}{{.Source}} -> {{.Destination}}{{println}}{{end}}'
|
||||
# Покажет: /run/desktop/mnt/host/c/... -> /custom/ <-- WSL2 9p
|
||||
|
||||
# 2. Rename one yml to .disabled, проверить route ещё активный
|
||||
docker exec traefik wget --header='Host: <some-host-in-disabled-yml>' --spider https://traefik/
|
||||
# 200 OK даже после rename (т.к. config не перезагружен)
|
||||
|
||||
# 3. После docker restart traefik — то же запрос вернёт 404
|
||||
docker restart traefik
|
||||
docker exec traefik wget --header='Host: <some-host-in-disabled-yml>' --spider https://traefik/
|
||||
# 404 ✅
|
||||
```
|
||||
|
||||
## Последствия
|
||||
|
||||
- **Любое изменение в `/custom/*.yml` требует `docker restart traefik`.**
|
||||
- Atomic revert: backup .yml → restart → rollback означает restore + restart.
|
||||
- "Hot reload" workflow невозможен под этой config'ом — нужно или native Linux Docker, или migrate на docker provider via labels (отдельные изменения сразу видны через container restart events).
|
||||
|
||||
## Workarounds
|
||||
|
||||
1. **Always restart traefik after config changes** — single source of truth для team is restart, не file-edit. Документировать.
|
||||
2. **Periodic auto-restart** — cron внутри traefik container (`docker exec traefik <restart-mechanism>`), e.g. каждый час. Кustомные disruption для уже работающих routes.
|
||||
3. **Migrate to docker provider** (labels) — labels на сервисах меняются вместе с container restart, traefik догоняет docker events корректно. Big migration работа.
|
||||
4. **Use traefik file provider's `pollInterval`** — НЕ поддерживается в file provider (только в HTTP provider). Не вариант.
|
||||
5. **Move traefik в WSL native** — запускать traefik внутри WSL2 distro (Ubuntu), mount /etc/traefik внутри WSL native fs, traefik видит inotify нормально. Требует переезд compose stack в WSL.
|
||||
|
||||
## Применено
|
||||
|
||||
[`traefik-maljarka-502-bug`](../../.tasks/traefik-maljarka-502-bug.md) — обнаружено при debugging. После рестарта traefik 2026-05-21:
|
||||
- 2 dead routes (sestech, ics-artmaterials) реально 404'нулись (до restart были active despite .disabled rename).
|
||||
- maljarka 502 не ушло — другая root cause (CMS-side HTTPS-mode crash для maljarka.tandemmebel.ru, см. cms-maljarka-https-mode-bug если создана).
|
||||
|
||||
## Ссылки
|
||||
|
||||
- Docker Desktop Windows mount perf: https://docs.docker.com/desktop/windows/wsl/
|
||||
- fsnotify limitations: https://github.com/fsnotify/fsnotify/issues/611 (9p/WSL2)
|
||||
- Setup на этом стэке: [[traefik-on-windows-docker-desktop]]
|
||||
Reference in New Issue
Block a user