Files
admin/cms-maljarka-https-mode-crash.md
vitya c727aaa1b6 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>
2026-05-21 10:53:02 +03:00

103 lines
4.8 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: 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).