test with blockpage

This commit is contained in:
2025-11-08 22:54:16 +01:00
parent c5a7f90226
commit 840ecf2953

144
main.go
View File

@@ -441,7 +441,8 @@ func handleTraefik(w http.ResponseWriter, r *http.Request) {
if len(matches) > 0 {
checkBlocked.Inc()
http.Error(w, "blocked", http.StatusForbidden)
errorhtml(w, r)
//http.Error(w, "blocked", http.StatusTooManyRequests)
return
}
w.WriteHeader(http.StatusOK)
@@ -650,3 +651,144 @@ func handleGUI(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
_, _ = w.Write([]byte(html))
}
func errorhtml(w http.ResponseWriter, r *http.Request) {
html := `<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Webserver ist nicht erreichbar - Fehler 521</title>
<style>
:root{
--bg:#f6f7f9;--text:#1f2937;--muted:#6b7280;--card:#ffffff;
--success:#22c55e;--danger:#ef4444;--accent:#2563eb;--border:#e5e7eb;
}
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--text);font:16px/1.5 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,"Helvetica Neue",Arial}
.wrap{max-width:980px;margin:0 auto;padding:40px 16px 64px}
header{display:flex;align-items:center;gap:12px;flex-wrap:wrap;}
h1{font-size:clamp(24px,4vw,38px);font-weight:700;margin:0}
.pill{display:inline-flex;align-items:center;gap:8px;padding:6px 10px;border-radius:999px;border:1px solid var(--border);background:#fff;font-weight:600;font-size:14px;color:#111}
.pill small{font-weight:500;color:var(--muted)}
p.lead{margin:12px 0 24px;color:var(--muted)}
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:18px;margin-top:16px}
.node{background:var(--card);border:1px solid var(--border);border-radius:14px;padding:18px;display:flex;flex-direction:column;align-items:center;gap:10px;box-shadow:0 6px 18px rgba(0,0,0,.04)}
.icon{position:relative;width:104px;height:80px;display:grid;place-items:center}
.status{position:absolute;right:-8px;bottom:-8px;width:30px;height:30px;border-radius:999px;display:grid;place-items:center;color:#fff;font-weight:800;font-size:14px}
.status.ok{background:var(--success)}
.status.err{background:var(--danger)}
.node h3{margin:6px 0 0;font-size:16px}
.node .sub{margin:0;color:var(--muted);font-size:14px}
.node .state{margin:4px 0 0;font-weight:700}
.state.ok{color:var(--success)}
.state.err{color:var(--danger)}
.actions{margin-top:28px;display:flex;gap:12px;flex-wrap:wrap}
.btn{border:1px solid var(--border);background:#fff;font-weight:600;padding:10px 14px;border-radius:10px;cursor:pointer}
.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff}
.meta{margin-top:24px;color:var(--muted);font-size:13px}
footer{margin-top:40px;color:var(--muted);font-size:13px}
/* Simple, friendly SVG look */
svg{display:block}
.dim{fill:#e5e7eb}
.stroke{stroke:#9ca3af}
</style>
</head>
<body>
<div class="wrap">
<header>
<h1>Webserver ist nicht erreichbar</h1>
<span class="pill">Fehlercode&nbsp;521 <small>(Origin Server verweigert Verbindung)</small></span>
</header>
<p class="lead">
Dein Browser funktioniert, der Edge-Proxy ist erreichbar - aber der Origin-Server antwortet nicht oder die Verbindung wird verweigert.
</p>
<section class="grid" aria-label="Diagnose-Kette">
<!-- You / Browser -->
<article class="node" aria-label="Browser Status">
<div class="icon" aria-hidden="true">
<!-- Browser icon -->
<svg width="88" height="62" viewBox="0 0 88 62" xmlns="http://www.w3.org/2000/svg" role="img">
<rect x="1" y="6" width="86" height="55" rx="8" fill="#fff" stroke="#d1d5db"/>
<rect x="1" y="1" width="86" height="14" rx="8" fill="#f3f4f6" stroke="#d1d5db"/>
<circle cx="10" cy="8" r="2.5" fill="#ef4444"/>
<circle cx="18" cy="8" r="2.5" fill="#f59e0b"/>
<circle cx="26" cy="8" r="2.5" fill="#22c55e"/>
</svg>
<div class="status ok" title="Funktioniert">✓</div>
</div>
<h3>Du</h3>
<p class="sub">Browser</p>
<p class="state ok">Funktioniert</p>
</article>
<!-- Edge / Proxy -->
<article class="node" aria-label="Edge/Proxy Status">
<div class="icon" aria-hidden="true">
<!-- Cloud icon -->
<svg width="96" height="64" viewBox="0 0 96 64" xmlns="http://www.w3.org/2000/svg" role="img">
<path d="M33 44h32a14 14 0 0 0 0-28 18 18 0 0 0-34-5 16 16 0 0 0-4 31z" fill="#e5e7eb" stroke="#d1d5db"/>
</svg>
<div class="status ok" title="Funktioniert">✓</div>
</div>
<h3>Edge-Proxy</h3>
<p class="sub">Zwischenschicht</p>
<p class="state ok">Funktioniert</p>
</article>
<!-- Host / Origin -->
<article class="node" aria-label="Origin/Host Status">
<div class="icon" aria-hidden="true">
<!-- Server icon -->
<svg width="88" height="62" viewBox="0 0 88 62" xmlns="http://www.w3.org/2000/svg" role="img">
<rect x="6" y="10" width="76" height="18" rx="4" fill="#f3f4f6" stroke="#d1d5db"/>
<circle cx="16" cy="19" r="3" fill="#9ca3af"/>
<rect x="6" y="34" width="76" height="18" rx="4" fill="#f3f4f6" stroke="#d1d5db"/>
<circle cx="16" cy="43" r="3" fill="#9ca3af"/>
</svg>
<div class="status err" title="Fehler">✕</div>
</div>
<h3>Host</h3>
<p class="sub">Origin-Server</p>
<p class="state err">Fehler</p>
</article>
</section>
<div class="actions">
<button class="btn primary" onclick="location.reload()">Erneut versuchen</button>
<button class="btn" onclick="document.getElementById('details').toggleAttribute('open')">Details anzeigen</button>
</div>
<details id="details" class="meta">
<summary><strong>Technische Details</strong></summary>
<ul>
<li>Fehler: <strong>521</strong> - Origin verweigert die Verbindung (z.&nbsp;B. Firewall, blockierter Port, kein Dienst am Ziel).</li>
<li>Zeit: <span id="now">-</span></li>
</ul>
<p>Tipps: Prüfe, ob dein Backend erreichbar ist (TCP/443 oder 80), ob der Dienst läuft und ob eine Firewall/Fail2ban/Rate-Limit die Proxy-IP blockiert.</p>
</details>
<footer>
<span>Wenn das Problem fortbesteht, kontaktiere den Betreiber der Website.</span>
</footer>
</div>
<script>
// Kleine Komfortfunktionen für die Detailbox
(function(){
const now = new Date()
document.getElementById('now').textContent = now.toLocaleString()
// Client IP lässt sich hier ohne Backend nicht sauber ermitteln - Platzhalter
})()
</script>
</body>
</html>`
w.Header().Set("Content-Type", "text/html; charset=utf-8")
_, _ = w.Write([]byte(html))
}