Caddy
Aus Internal Liorith Wiki
Weitere Optionen
Installation
- Offizielle Website: https://caddyserver.com/
- Pakete für Linux/Ubuntu/Debian:
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
- Offizielle Doku: https://caddyserver.com/docs/
- GitHub: https://github.com/caddyserver/caddy
- Community Forum: https://caddy.community/