Files
htl-reverse-proxy-tls-lab/proxy/html/challenges.html
T
hkoeck 79a13f0919 Verbessere Challenge-Angaben, TLS-Fixes und Windows-Tauglichkeit
Fachliche Fixes:
- Easy-RSA: explizites --subject-alt-name (SAN) ergaenzt, sonst
  scheitert curl trotz CA-Import
- HSTS: max-age auf 3600 reduziert, includeSubDomains erklaert,
  Warnung zur host-weiten Browser-Falle + Reset-Weg
- Challenge 9: Backup-/Restore-Schritte fuer nginx.conf
- Compose-Portwechsel: redeploy statt proxy-reload klargestellt
- log_format-Platzierung (http-Block) dokumentiert
- add_header-Vererbungsfalle erklaert (Ch. 4 + Abgrenzung Ch. 8)

Angabe-Struktur (alle 13 Challenges):
- Einheitliches Schema: Ausgangszustand, Schritte (Muss),
  Zielzustand/Akzeptanz, erwartete Done-Check-Ausgaben
- Arbeitsweise global geklaert (additiv, Ausnahme Ch. 9, Reset)

Robustheit/Kosmetik:
- Load-Balancing: eindeutiger INSTANCE-Marker statt fragilem grep
- Challenge-3-Titel auf "Alias-Route" korrigiert
- HTTPS_PORT in .env.example parametrisiert
- Umlaut-Konsistenz (ASCII)

Windows-Tauglichkeit:
- Klargestellt: Test-Kommandos laufen in WSL bash, nicht PowerShell
  (curl-Alias-Falle), Stack-Steuerung per Wrapper oder WSL
- Wireshark: empfohlener Capture-Weg in WSL (tshark), npcap-Hinweis
- CA-Import: Linux-Trust-Store (WSL) vs Windows-Browser (certutil)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 22:08:41 +02:00

346 lines
16 KiB
HTML

<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTL Workshop Challenges</title>
<style>
:root {
--bg: #081825;
--panel: #10273d;
--panel-soft: #163450;
--text: #e9f2fb;
--muted: #b7cbdf;
--accent: #4ecdc4;
--easy: #59d68a;
--medium: #ffd166;
--hard: #ff7b72;
--expert: #6fb6ff;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: "Fira Sans", "Segoe UI", sans-serif;
color: var(--text);
background:
radial-gradient(circle at 100% 0%, #1f4060 0%, transparent 45%),
radial-gradient(circle at 0% 100%, #14324a 0%, transparent 35%),
var(--bg);
min-height: 100vh;
padding: 1.2rem;
}
main {
width: min(1150px, 100%);
margin: 0 auto;
display: grid;
gap: 1rem;
}
.panel {
background: var(--panel);
border: 1px solid #315678;
border-radius: 14px;
padding: 1.1rem;
}
h1,
h2,
h3 {
margin-top: 0;
}
p,
li {
color: var(--muted);
line-height: 1.5;
}
a {
color: var(--accent);
}
code {
font-family: "JetBrains Mono", "Fira Code", "Consolas", "Liberation Mono", monospace;
font-size: 0.92em;
background: #0d1f31;
border: 1px solid #2d4f6e;
border-radius: 6px;
padding: 0.1rem 0.35rem;
}
pre {
background: #0b2133;
border: 1px solid #2b5578;
border-radius: 10px;
padding: 0.75rem 0.85rem;
overflow-x: auto;
margin: 0.65rem 0;
}
pre code {
display: block;
background: transparent;
border: 0;
border-radius: 0;
padding: 0;
font-size: 0.92rem;
line-height: 1.45;
white-space: pre;
}
.top-links {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.pill {
display: inline-block;
text-decoration: none;
background: #11314b;
border: 1px solid #2a5d84;
border-radius: 999px;
padding: 0.35rem 0.75rem;
}
.badge {
display: inline-block;
border-radius: 999px;
padding: 0.15rem 0.5rem;
font-size: 0.8rem;
font-weight: 700;
margin-bottom: 0.45rem;
}
.easy {
color: #08210f;
background: var(--easy);
}
.medium {
color: #312200;
background: var(--medium);
}
.hard {
color: #3b0905;
background: var(--hard);
}
.expert {
color: #031c37;
background: var(--expert);
}
details {
background: var(--panel-soft);
border: 1px solid #2d5577;
border-radius: 12px;
padding: 0.75rem 0.85rem;
margin-bottom: 0.7rem;
}
details:last-child {
margin-bottom: 0;
}
summary {
cursor: pointer;
font-weight: 700;
}
.kw {
color: #e9f2fb;
font-weight: 700;
}
</style>
</head>
<body>
<main>
<section class="panel">
<h1>Challenges - Reverse Proxy & TLS</h1>
<p>Manuelle Proxy-Konfiguration, Security-Entscheidungen und TLS von Grund auf.</p>
<div class="top-links">
<a class="pill" href="/">Startseite</a>
<a class="pill" href="/challenges.html">Challenges</a>
<a class="pill" href="/hints.html">Hints</a>
<a class="pill" href="/solutions.html">Solutions</a>
<a class="pill" href="/service/a">Backend A</a>
<a class="pill" href="/service/b">Backend B</a>
<a class="pill" href="/challenges.html#challenge-2-backend-c">Backend C (ab C2)</a>
</div>
</section>
<section class="panel">
<h2>Wo laufen die Kommandos? (Windows)</h2>
<p>Stack steuern geht aus PowerShell (<code>scripts/workshop.ps1</code>) <b>oder</b> WSL. Aber <b>alle</b> Test-Kommandos (<code>curl</code>, <code>openssl</code>, <code>grep</code>, <code>for</code>-Schleifen, <code>./scripts/compose.sh</code>) laufen im <b>WSL-Terminal (bash)</b>.</p>
<p><span class="kw">Warnung:</span> In PowerShell ist <code>curl</code> ein Alias fuer <code>Invoke-WebRequest</code> und versteht <code>-I</code>/<code>-k</code>/<code>--cacert</code> nicht. Immer im WSL-Terminal testen.</p>
</section>
<section class="panel">
<h2>Abgabe-Format</h2>
<ul>
<li>1-3 Minuten Demo</li>
<li>Done-Check live ausfuehren</li>
<li>2-3 Saetze: was, warum, welche Wirkung</li>
</ul>
</section>
<section class="panel">
<h2>Easy</h2>
<details>
<summary><span class="badge easy">Easy</span> 1) Routing verstehen (aktiv)</summary>
<p><span class="kw">Muss:</span> zuerst in <code>proxy/nginx.conf</code> nachsehen, dann testen.</p>
<p><span class="kw">Warum wichtig:</span> Routing ist die Grundfunktion jedes Reverse Proxys - ohne sauberes Matching ist alles andere instabil.</p>
<ul>
<li>Welche <code>location</code> matched <code>/service/a</code>?</li>
<li>Welcher <code>upstream</code> wird verwendet?</li>
</ul>
<p><span class="kw">Zielzustand:</span> Du kannst Location &rarr; Upstream &rarr; Backend benennen und begruenden, warum A und B unterschiedlich antworten.</p>
<pre><code>curl http://localhost:8080/service/a # -&gt; "Target A"
curl http://localhost:8080/service/b # -&gt; "Target B"</code></pre>
</details>
<details id="challenge-2-backend-c">
<summary><span class="badge easy">Easy</span> 2) backend-c hinzufuegen</summary>
<p><span class="kw">Muss:</span> Compose-Service + Upstream + Route <code>/service/c</code>.</p>
<p><span class="kw">Zusatz:</span> <code>backends/c/index.html</code> ist vorhanden und darf angepasst werden.</p>
<p><span class="kw">Warum wichtig:</span> Neue Services kommen laufend dazu; Erweiterungen ohne Seiteneffekte sind Praxisalltag.</p>
<p><span class="kw">Zielzustand:</span> <code>/service/c</code> liefert Backend C; A und B laufen unveraendert weiter.</p>
<pre><code>curl http://localhost:8080/service/c # -&gt; "Reverse Proxy Target C"
curl http://localhost:8080/service/a # -&gt; weiterhin "Target A"
curl http://localhost:8080/service/b # -&gt; weiterhin "Target B"</code></pre>
</details>
<details>
<summary><span class="badge easy">Easy</span> 3) Eigene Route /demo/a</summary>
<p><span class="kw">Muss:</span> Alias-Route bauen, die auf Backend A fuehrt.</p>
<p><span class="kw">Warum wichtig:</span> Der Proxy entkoppelt externe Pfade von internen Backend-Implementierungen.</p>
<p><span class="kw">Zielzustand:</span> <code>/demo/a</code> liefert dieselbe Antwort wie <code>/service/a</code>.</p>
<pre><code>curl http://localhost:8080/demo/a # -&gt; "Target A"</code></pre>
</details>
</section>
<section class="panel">
<h2>Medium</h2>
<details>
<summary><span class="badge medium">Medium</span> 4) Security Headers</summary>
<p>Setze mindestens <code>nosniff</code>, <code>DENY</code>, <code>strict-origin-when-cross-origin</code>, <code>Permissions-Policy</code>, <code>COOP</code>, <code>CORP</code>.</p>
<p><span class="kw">Optional:</span> CSP fuer statische Seiten.</p>
<p><span class="kw">Warum wichtig:</span> Diese Header reduzieren konkrete Browser-Angriffsvektoren und gehoeren zur Security-Baseline.</p>
<p><span class="kw">Fallstrick:</span> Header im <code>server {}</code>-Block setzen. Sobald in einem <code>location {}</code> ein <code>add_header</code> steht, verwirft Nginx dort <b>alle</b> Server-Header &rarr; dann erneut setzen.</p>
<p><span class="kw">Zielzustand:</span> <code>curl -I /</code> zeigt alle geforderten Security-Header.</p>
<pre><code>curl -I http://localhost:8080/ # -&gt; nosniff, DENY, Referrer-Policy, Permissions-Policy, COOP, CORP</code></pre>
</details>
<details>
<summary><span class="badge medium">Medium</span> 5) Interne Route absichern</summary>
<p><span class="kw">Muss:</span> <code>/internal/status</code> nur fuer <code>127.0.0.1</code>.</p>
<p><span class="kw">Wichtig:</span> Host-Request zeigt typischerweise 403 (Docker-Netzwerk).</p>
<p><span class="kw">Warum wichtig:</span> Nicht jeder Endpoint darf oeffentlich erreichbar sein; Netzsegmentierung beginnt oft am Proxy.</p>
<p><span class="kw">Zielzustand:</span> Host &rarr; 403; container-intern (127.0.0.1) &rarr; Antwort.</p>
<pre><code>curl -i http://localhost:8080/internal/status # -&gt; 403 (vom Host)
./scripts/compose.sh exec -T reverse-proxy sh -lc "wget -qO- http://127.0.0.1/internal/status" # -&gt; "internal ok"</code></pre>
</details>
<details>
<summary><span class="badge medium">Medium</span> 6) Logging verbessern</summary>
<p>Eigenes <code>log_format</code> mit Upstream-Infos einbauen.</p>
<p><span class="kw">Hinweis:</span> <code>log_format</code> gehoert in den <code>http {}</code>-Block, sonst startet Nginx nicht.</p>
<p><span class="kw">Warum wichtig:</span> Ohne brauchbare Logs dauert Fehleranalyse deutlich laenger und Incident-Response wird unzuverlaessig.</p>
<p><span class="kw">Zielzustand:</span> Log-Zeile im neuen Format mit Upstream-Infos (<code>upstream=...</code>, <code>urt=...</code>).</p>
<pre><code>curl http://localhost:8080/service/a
./scripts/compose.sh logs reverse-proxy # -&gt; neue Zeile mit upstream=... urt=...</code></pre>
</details>
<details>
<summary><span class="badge medium">Medium</span> 7) Load Balancing</summary>
<p>Zweite Instanz von Backend A (<code>backend-a2</code>) einbauen und Round-Robin zeigen.</p>
<p><span class="kw">Warum wichtig:</span> Lastverteilung ist Kernnutzen eines Reverse Proxys fuer Skalierung und Verfuegbarkeit.</p>
<p><span class="kw">Zielzustand:</span> Ueber mehrere Requests antworten <b>beide</b> Instanzen (Mischung aus A und A2).</p>
<pre><code>for i in $(seq 1 8); do
curl -s http://localhost:8080/service/a | grep -o "INSTANCE=[A-Za-z0-9]*"
done # -&gt; Mischung aus "INSTANCE=A" und "INSTANCE=A2"</code></pre>
</details>
<details>
<summary><span class="badge medium">Medium</span> 8) Response Header Minimization</summary>
<p>Mindestens einen Backend-Response-Header per <code>proxy_hide_header</code> ausblenden.</p>
<p><span class="kw">Abgrenzung zu #4:</span> #4 setzt Schutz-Header, #8 entfernt unnoetige Header aus Upstream-Responses.</p>
<p><span class="kw">Warum wichtig:</span> Weniger preisgegebene Metadaten erschweren Fingerprinting und zielgerichtete Angriffe.</p>
<p><span class="kw">Zielzustand:</span> Der ausgeblendete Header (z. B. <code>ETag</code>) fehlt jetzt in der Antwort.</p>
<pre><code>curl -I http://localhost:8080/service/a # -&gt; ETag/Last-Modified nicht mehr vorhanden</code></pre>
</details>
<details>
<summary><span class="badge medium">Medium</span> 9) Debugging Challenge</summary>
<p>Mit <code>proxy/nginx.broken.conf</code> arbeiten, Fehler finden und reparieren.</p>
<p><span class="kw">Zuerst sichern:</span> diese Challenge ueberschreibt deine <code>nginx.conf</code> &rarr; vorher <code>cp proxy/nginx.conf proxy/nginx.conf.bak</code>, am Ende zurueckkopieren.</p>
<p><span class="kw">Warum wichtig:</span> In der Praxis geht es oft um Diagnose unter Zeitdruck, nicht nur um Greenfield-Konfiguration.</p>
<p><span class="kw">Typische Fehler in der kaputten Datei:</span> Upstream-Name-Mismatch, falscher Port, fehlender Trailing Slash in <code>proxy_pass</code>.</p>
<p><span class="kw">Zielzustand:</span> Nach den Fixes liefern A und B wieder ihre Backends; Nginx startet fehlerfrei.</p>
<pre><code>curl http://localhost:8080/service/a # -&gt; "Target A"
curl http://localhost:8080/service/b # -&gt; "Target B"
./scripts/compose.sh logs reverse-proxy</code></pre>
</details>
</section>
<section class="panel">
<h2>Hard (TLS)</h2>
<details>
<summary><span class="badge hard">Hard</span> 10) HTTPS von 0 (Easy-RSA)</summary>
<p>Zertifikat fuer <code>localhost</code>, Port <code>8443:443</code>, Root-CA importiert.</p>
<p><span class="kw">Wichtig:</span> Der neue Port ist eine Compose-Aenderung &rarr; mit <code>make redeploy</code> deployen, nicht nur <code>make proxy-reload</code>.</p>
<p><span class="kw">Warum wichtig:</span> TLS-Grundaufbau ist Voraussetzung fuer vertrauliche und manipulationssichere Kommunikation.</p>
<p><span class="kw">Zielzustand:</span> Aufruf liefert Backend A <b>ohne</b> <code>-k</code> (kein SAN-/Zertifikatsfehler). Zertifikat mit SAN signieren!</p>
<pre><code>curl https://localhost:8443/service/a # -&gt; Backend A, KEIN "SSL certificate problem"</code></pre>
</details>
<details>
<summary><span class="badge hard">Hard</span> 11) HTTP -&gt; HTTPS Redirect</summary>
<p><span class="kw">Voraussetzung:</span> Challenge 10 abgeschlossen. Bestehende Config weiterverwenden.</p>
<p><span class="kw">Warum wichtig:</span> Redirect verhindert unabsichtliche Klartext-Nutzung und erzwingt den sicheren Transport.</p>
<p><span class="kw">Zielzustand:</span> HTTP auf <code>8080</code> antwortet mit <code>301</code> und <code>Location: https://localhost:8443/...</code>.</p>
<pre><code>curl -I http://localhost:8080/service/a # -&gt; 301, Location: https://localhost:8443/service/a</code></pre>
</details>
<details>
<summary><span class="badge hard">Hard</span> 12) TLS Haertung + Chain + HSTS</summary>
<p><span class="kw">Voraussetzung:</span> Challenge 10 und 11 abgeschlossen. Gleiche Config weiter erweitern.</p>
<p><span class="kw">Warum wichtig:</span> Erst Haertung + HSTS reduzieren Downgrade-Risiken und sorgen fuer dauerhaft sichere Clients.</p>
<p><span class="kw">Warnung (HSTS-Falle):</span> Der Browser merkt sich HSTS host-weit fuer <code>localhost</code> (nicht pro Port). Nach <code>https://localhost:8443</code> wird auch <code>http://localhost:8080</code> auf https erzwungen. Zum Testen <code>curl</code> nutzen; Browser-HSTS ggf. unter <code>chrome://net-internals/#hsts</code> fuer <code>localhost</code> loeschen. <code>max-age</code> ist im Lab bewusst kurz (1h).</p>
<p><span class="kw">Zielzustand:</span> <code>curl -I</code> zeigt <code>Strict-Transport-Security</code>; <code>s_client</code> verhandelt TLSv1.2/1.3 mit <code>Verify return code: 0 (ok)</code>.</p>
<pre><code>curl -I https://localhost:8443/service/a # -&gt; enthaelt Strict-Transport-Security
openssl s_client -connect localhost:8443 -servername localhost</code></pre>
</details>
</section>
<section class="panel">
<h2>Bonus Expert</h2>
<details>
<summary><span class="badge expert">Expert</span> 13) Wireshark: HTTP vs HTTPS sauber ausarbeiten</summary>
<p><span class="kw">Warum wichtig:</span> Sichtbarkeit auf Paketebene macht den Sicherheitsgewinn von TLS fuer alle nachvollziehbar.</p>
<ol>
<li>HTTP auf <code>8080</code> mitschneiden und Klartext zeigen.</li>
<li>HTTPS auf <code>8443</code> mitschneiden.</li>
<li><code>ClientHello</code>, <code>ServerHello</code>, <code>Certificate</code> markieren.</li>
<li>3-5 Bulletpoints: was ist sichtbar, was ist geschuetzt?</li>
</ol>
<p><span class="kw">Optional:</span> TLS Decrypt mit <code>SSLKEYLOGFILE</code>.</p>
<p><span class="kw">Zielzustand:</span> HTTP-Mitschnitt zeigt Pfad/Header im Klartext; HTTPS zeigt nur den Handshake, Nutzdaten ohne Key nicht lesbar.</p>
<p><span class="kw">Abgabe:</span> mind. 3 Screenshots + technische Interpretation.</p>
</details>
</section>
</main>
</body>
</html>