import: merge .wiki/concepts/ from temp prefix into existing dir (history preserved via merge+rename)
This commit is contained in:
102
.wiki/concepts/cms-maljarka-https-mode-crash.md
Normal file
102
.wiki/concepts/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).
|
||||
Reference in New Issue
Block a user