Menü aufrufen
Toggle preferences menu
Persönliches Menü aufrufen
Nicht angemeldet
Ihre IP-Adresse wird öffentlich sichtbar sein, wenn Sie Änderungen vornehmen.

Caddy: Unterschied zwischen den Versionen

Aus Internal Liorith Wiki
Initiale erstellung
 
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
= Caddy =
= Installation =
 
== Installation ==
* Offizielle Website: https://caddyserver.com/
* Offizielle Website: https://caddyserver.com/
* Pakete für Linux/Ubuntu/Debian:
* Pakete für Linux/Ubuntu/Debian:
Zeile 16: Zeile 14:
   </nowiki>
   </nowiki>


== Grundkonfiguration ==
= Grundkonfiguration =
* Caddyfile Beispiel:
* Caddyfile Beispiel:
   <nowiki>
   <nowiki>
Zeile 28: Zeile 26:
   * Domain muss auf die öffentliche IP zeigen.   
   * Domain muss auf die öffentliche IP zeigen.   


== TLS / Let’s Encrypt ==
= TLS / Let’s Encrypt =
* Automatische Zertifikate:
* Automatische Zertifikate:
   * Aktivieren durch einfaches Setzen der Domain in der Caddyfile.   
   * Aktivieren durch einfaches Setzen der Domain in der Caddyfile.   
Zeile 43: Zeile 41:
   * Für lokale Tests `localhost` + self-signed Zertifikat.
   * Für lokale Tests `localhost` + self-signed Zertifikat.


== Reverse Proxy ==
= Reverse Proxy =
* Einfaches Beispiel:
* Einfaches Beispiel:
   <nowiki>
   <nowiki>
Zeile 62: Zeile 60:
   </nowiki>
   </nowiki>


== Common Problems ==
= Common Problems =
* Caddy startet nicht:
* Caddy startet nicht:
   * Prüfe Port 80/443, evtl. andere Prozesse blockieren.   
   * Prüfe Port 80/443, evtl. andere Prozesse blockieren.   
Zeile 70: Zeile 68:
   * `caddy reload` verwenden.   
   * `caddy reload` verwenden.   


== Snippets / Copy-Paste ==
= Snippets / Copy-Paste =
* HTTP → HTTPS redirect:
* HTTP → HTTPS redirect:
   <nowiki>
   <nowiki>
Zeile 86: Zeile 84:
   </nowiki>
   </nowiki>


== Quellen / Links ==
= Quellen / Links =
* Offizielle Doku: https://caddyserver.com/docs/
* Offizielle Doku: https://caddyserver.com/docs/
* GitHub: https://github.com/caddyserver/caddy
* GitHub: https://github.com/caddyserver/caddy
* Community Forum: https://caddy.community/
* Community Forum: https://caddy.community/

Version vom 7. Februar 2026, 21:08 Uhr

Installation

   sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
   curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
   curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
   sudo apt update
   sudo apt install caddy
   
  • Docker:
 
  docker run -d --name caddy -p 80:80 -p 443:443 -v caddy_data:/data -v caddy_config:/config caddy
  

Grundkonfiguration

  • Caddyfile Beispiel:
 
  :80 {
      root * /var/www/html
      file_server
  }
  
  • Auto-HTTPS:
 * Caddy erstellt automatisch Zertifikate für Domains.  
 * Domain muss auf die öffentliche IP zeigen.  

TLS / Let’s Encrypt

  • Automatische Zertifikate:
 * Aktivieren durch einfaches Setzen der Domain in der Caddyfile.  
  • Manuelle Konfiguration:
 
  :443 {
      tls you@example.com
      root * /var/www/html
      file_server
  }
  
  • Tipps:
 * Prüfe Logs mit `caddy list-modules` und `journalctl -u caddy`.  
 * Für lokale Tests `localhost` + self-signed Zertifikat.

Reverse Proxy

  • Einfaches Beispiel:
 
  example.com {
      reverse_proxy localhost:3000
  }
  
  • Mit Pfaden:
 
  example.com {
      handle /api/* {
          reverse_proxy localhost:5000
      }
      handle {
          reverse_proxy localhost:3000
      }
  }
  

Common Problems

  • Caddy startet nicht:
 * Prüfe Port 80/443, evtl. andere Prozesse blockieren.  
  • Zertifikatfehler:
 * DNS korrekt gesetzt? Firewall Ports offen?  
  • Konfigurationsänderungen nicht übernommen:
 * `caddy reload` verwenden.  

Snippets / Copy-Paste

  • HTTP → HTTPS redirect:
 
  http://example.com {
      redir https://example.com{uri}
  }
  
  • Static files + SPA fallback:
 
  example.com {
      root * /var/www/html
      file_server
      try_files {path} /index.html
  }
  

Quellen / Links