Files
admin/.tasks-imported/traefik-maljarka-502-bug.md
vitya 85b3ee847f import-stage: .tasks/ via split (temp prefix, await STATUS.md merge)
git-subtree-dir: .tasks-imported
git-subtree-mainline: c40418239e
git-subtree-split: cbdc2b39aa
2026-05-21 13:48:02 +03:00

56 lines
3.3 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.
# traefik-maljarka-502-bug
## Goal
Разобраться почему `maljarka.tandemmebel.ru` через traefik HTTPS возвращает 502 Bad Gateway, хотя backend (IIS на host:8089 с правильным Host header) отвечает 200 OK с валидным CMS body.
## Evidence (2026-05-21)
| Path | Result |
|---|---|
| `docker exec traefik wget --spider https://maljarka.tandemmebel.ru/` | **HTTP/1.1 502 Bad Gateway** |
| `docker exec traefik wget --header='Host: maljarka.tandemmebel.ru' http://host.docker.internal:8089/` | **HTTP/1.1 200 OK** (Microsoft-IIS/10.0, 43730 bytes, "Малярка от Тандеммебель") |
| `Invoke-WebRequest http://localhost:8089/ -Headers @{Host='maljarka.tandemmebel.ru'}` | **200 OK** (host->host direct) |
| `docker exec traefik wget --spider https://www.tandemmebel.ru/` | **200 OK** (sibling route, working) |
## Config diff
`maljarka.yml` vs `tandemmebel.yml` — syntactically identical (router→service→loadBalancer→servers, same backend URL `http://host.docker.internal:8089/`, same `passHostHeader: true`). LE cert для `maljarka.tandemmebel.ru` присутствует в `acme.json`.
## Hypotheses
1. **Stale traefik state** — uptime 38h+ с регулярными `docker provider connection error` retry-loop'ами. Restart traefik может сбросить bad state. **Easy first check.**
2. **Hidden file encoding difference** — BOM / line endings / trailing whitespace в `maljarka.yml` vs `tandemmebel.yml`. `Get-FileHash` оба yml + `Format-Hex` на первые 16 байт.
3. **acme.json corruption для maljarka cert** — cert exists но key/chain broken. Traefik не может handshake → fallback вернёт 502? Maybe.
4. **Service name collision**`maljarka` router/service name conflicts c чем-то ещё в dynamic config. Vrai unlikely (grep подтвердил unique).
5. **Backend connection limit** — service-specific. Маловероятно.
## Implementation sketch
```powershell
# 1. Get exact error body from traefik
docker exec traefik wget -O - --server-response https://maljarka.tandemmebel.ru/ 2>&1 | Select-Object -First 30
# 2. Enable traefik access logs если не включены (data/traefik.yml accessLog: filePath)
docker exec traefik cat /etc/traefik/traefik.yml | Select-String 'accessLog'
# 3. Restart traefik (brief ~1-2s interruption ВСЕХ routes)
docker restart traefik
Start-Sleep 5
docker exec traefik wget --spider https://maljarka.tandemmebel.ru/ 2>&1 | Select-Object -First 3
# 4. Bytewise compare yml files
Get-FileHash *.yml -Algorithm MD5 | Where-Object Path -Match '(maljarka|tandemmebel)\.yml$'
Get-Content C:\...\maljarka.yml -Raw -Encoding Byte | Format-Hex | Select-Object -First 5
```
## Open questions
- [ ] Является ли `maljarka.tandemmebel.ru` критичным для бизнеса (real traffic) или это test-subdomain? Если real — bump priority.
- [ ] Существует ли site binding для этого hostname в IIS `snolla` site, или CMS catch-all'ит через `*` binding?
## Notes
- Скоприровано из close-out [[iis-traefik-dead-routes-cleanup]] как side-finding.
- Атомарных изменений на инфре не делал — задача чисто диагностическая.