Cloudflare Tunnel 502 Recovery (brain.id86.net)
This document records exactly what was done to restore brain.id86.net after a 502 incident in a Docker + Cloudflare Tunnel + Zero Trust setup.
Incident Summary
- Symptom:
brain.id86.netreturned 502 Bad Gateway. - Tunnel log:
Unable to reach the origin service ... connect: connection refused. - Affected origin mapping:
brain.id86.netrouted tohttp://docusaurus:3000. - Root behavior:
docusauruscontainer was frequently unavailable during build/start cycles.
Root Causes Confirmed
docusaurusstartup command performs full install/build on restart, causing long origin downtime.- New WP-CLI cheatsheet docs had MDX table syntax errors, causing build failures/restarts.
- Tunnel pointed to the unstable origin (
docusaurus) during recovery window.
What Was Fixed
1) Fixed MDX syntax issues in cheatsheet docs
Affected folder:
docs/wordpress/wp-cli/16. Cheatsheet
Actions:
- Escaped angle bracket placeholders inside table cells (
<...>). - Replaced pipe-style alternatives inside syntax strings (for example
id|login) with safe text labels (id-or-login). - Removed invalid MDX patterns that broke parser/SSG.
Verification command used:
sudo docker exec docusaurus sh -lc 'cd /app && npm run build'
2) Cleared stale Docusaurus/Webpack build cache
This removed stale references still pointing to old doc IDs.
sudo docker exec docusaurus sh -lc 'rm -rf /app/.docusaurus /app/node_modules/.cache'
3) Corrected tunnel ingress to a stable origin (temporary recovery path)
File updated:
/opt/docker-data/tunnel/config/config.yml
Change applied:
brain.id86.netwas kept onhttp://docusaurus:3000after production stabilized.
Then reloaded tunnel:
sudo docker restart cloudflared
Validation After Recovery
curl -I https://brain.id86.netreturned Cloudflare Access redirect (302), not 502.- Cloudflare tunnel stopped reporting fresh
Unable to reach originerrors forbrain.id86.netafter remap. - Site became reachable again through Zero Trust login flow.
Useful Commands Used During Incident
# container status
sudo docker ps --format 'table {{.Names}}\t{{.Status}}'
# docusaurus logs
sudo docker logs --tail 200 docusaurus
# tunnel logs
sudo docker logs --tail 200 cloudflared
# inspect docusaurus process state
sudo docker exec docusaurus sh -lc 'ps -ef | grep -E "docusaurus|node|serve" | grep -v grep'
# test public endpoint
curl -I -m 15 https://brain.id86.net
Recommended Permanent Hardening
- Change production
docusauruscontainer strategy to avoid full build on every restart. - Keep
brain.id86.netmapped to the stable origin only after health checks pass. - Run MDX/build validation before reload/restart during content migrations.
- Add a healthcheck and operational runbook for tunnel/origin failover.
Follow-Up: Production Route Confirmed
After stability checks, ingress remained on production origin:
brain.id86.net->http://docusaurus:3000