Caddy Reverse Proxy Anleitung 2026: Automatisches HTTPS leicht gemacht
TUTORIAL 12 min read fordnox

Caddy Reverse Proxy Anleitung 2026: Automatisches HTTPS leicht gemacht

Caddy als Reverse Proxy einrichten mit automatischem HTTPS, konfigurationsfreiem SSL und einfacher Caddyfile-Syntax. Komplette VPS-Bereitstellungsanleitung.


Caddy Reverse Proxy Anleitung: Automatisches HTTPS leicht gemacht

Caddy ist der Webserver, der HTTPS standardmaeßig aktiviert. Kein certbot, keine Cron-Jobs, keine Erneuerungsskripte. Richten Sie eine Domain auf Caddy und es holt sich automatisch ein Zertifikat.

Was ist Caddy?

Caddy sitzt zwischen dem Internet und Ihren Diensten:

Internet → Caddy → Service A (app.domain.com)
                 → Service B (api.domain.com)
                 → Service C (admin.domain.com)

Warum Entwickler Caddy lieben:

Caddy vs Nginx vs Traefik

FunktionCaddyNginxTraefik
Auto HTTPSStandardCertbot erforderlichIntegriert
KonfigurationssyntaxEinfachMittelKomplex
Docker-IntegrationGutManuellNativ
LeistungAusgezeichnetAusgezeichnetAusgezeichnet
PluginsGo-ModuleC-ModuleMiddleware
Konfig-ReloadOhne AusfallzeitSignal erforderlichHot Reload
LernkurveNiedrigMittelHoeher

Caddy gewinnt bei der Einfachheit. Wenn Sie den einfachsten Reverse-Proxy-Setup moechten, ist dies die richtige Wahl. Sehen Sie unsere Traefik Docker Anleitung fuer Container-natives Routing.

VPS-Anforderungen

Caddy ist extrem leichtgewichtig:

Ihre VPS-Dimensionierung haengt von Ihren Backend-Diensten ab, nicht von Caddy. Lesen Sie unseren Bester VPS fuer Docker Leitfaden fuer Empfehlungen zur Dimensionierung.

Caddy installieren

Option 1: Paketmanager (Debian/Ubuntu)

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

Option 2: Docker

# docker-compose.yml
services:
  caddy:
    image: caddy:2-alpine
    container_name: caddy
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
      - 443:443/udp  # HTTP/3
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config

volumes:
  caddy_data:
  caddy_config:

Option 3: Einzelne Binaerdatei

curl -sS https://webi.sh/caddy | sh

Einfacher Reverse Proxy

Das einfachste Caddyfile

app.domain.com {
    reverse_proxy localhost:3000
}

Das ist alles. Caddy wird:

Mehrere Dienste

app.domain.com {
    reverse_proxy localhost:3000
}

api.domain.com {
    reverse_proxy localhost:8080
}

admin.domain.com {
    reverse_proxy localhost:9000
}

Jede Domain erhaelt automatisch ihr eigenes Zertifikat.

Docker Reverse Proxy Einrichtung

Schritt 1: Projektverzeichnis erstellen

mkdir -p /opt/caddy
cd /opt/caddy

Schritt 2: Docker Compose

# docker-compose.yml
services:
  caddy:
    image: caddy:2-alpine
    container_name: caddy
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
      - 443:443/udp
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config
    networks:
      - caddy

  whoami:
    image: traefik/whoami
    container_name: whoami
    networks:
      - caddy

networks:
  caddy:
    name: caddy

volumes:
  caddy_data:
  caddy_config:

Schritt 3: Caddyfile

test.domain.com {
    reverse_proxy whoami:80
}

Schritt 4: Starten

docker compose up -d

Besuchen Sie https://test.domain.com — es funktioniert mit vollem HTTPS.

Weitere Docker-Dienste hinzufuegen

Jeder Dienst im caddy-Netzwerk kann als Proxy eingerichtet werden:

# separate docker-compose.yml
services:
  myapp:
    image: myapp:latest
    container_name: myapp
    networks:
      - caddy

networks:
  caddy:
    external: true

Dann zum Caddyfile hinzufuegen:

myapp.domain.com {
    reverse_proxy myapp:8080
}

Caddy neu laden:

docker exec caddy caddy reload --config /etc/caddy/Caddyfile

Pfadbasiertes Routing

Routing nach Pfad

domain.com {
    handle /api/* {
        reverse_proxy localhost:8080
    }

    handle /admin/* {
        reverse_proxy localhost:9000
    }

    handle {
        reverse_proxy localhost:3000
    }
}

Pfadpraefix entfernen

domain.com {
    handle_path /api/* {
        reverse_proxy localhost:8080
    }
}

handle_path entfernt das uebereinstimmende Praefix. /api/users wird zu /users fuer das Backend.

Lastverteilung

Round Robin (Standard)

app.domain.com {
    reverse_proxy app1:3000 app2:3000 app3:3000
}

Mit Gesundheitspruefungen

app.domain.com {
    reverse_proxy app1:3000 app2:3000 {
        health_uri /health
        health_interval 10s
        health_timeout 5s
    }
}

Sticky Sessions

app.domain.com {
    reverse_proxy app1:3000 app2:3000 {
        lb_policy cookie
    }
}

Wenigste Verbindungen

app.domain.com {
    reverse_proxy app1:3000 app2:3000 {
        lb_policy least_conn
    }
}

Sicherheit

Einfache Authentifizierung

# Passwort-Hash generieren
caddy hash-password --plaintext 'your-secure-password'
admin.domain.com {
    basicauth {
        admin $2a$14$Zkx19...hashed...password
    }
    reverse_proxy localhost:9000
}

IP-Whitelist

admin.domain.com {
    @blocked not remote_ip 192.168.1.0/24 10.0.0.0/8
    respond @blocked 403

    reverse_proxy localhost:9000
}

Ratenbegrenzung

api.domain.com {
    rate_limit {
        zone dynamic {
            key {remote_host}
            events 100
            window 1m
        }
    }
    reverse_proxy localhost:8080
}

Sicherheitsheader

domain.com {
    header {
        Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
        X-Content-Type-Options "nosniff"
        X-Frame-Options "DENY"
        Referrer-Policy "strict-origin-when-cross-origin"
        -Server
    }
    reverse_proxy localhost:3000
}

Die -Server-Direktive entfernt den Server-Header aus den Antworten.

Wildcard-Zertifikate

Fuer *.domain.com verwenden Sie die DNS-Challenge:

*.domain.com {
    tls {
        dns cloudflare {env.CF_API_TOKEN}
    }

    @app host app.domain.com
    handle @app {
        reverse_proxy localhost:3000
    }

    @api host api.domain.com
    handle @api {
        reverse_proxy localhost:8080
    }
}

Caddy mit dem Cloudflare DNS-Modul bauen:

xcaddy build --with github.com/caddy-dns/cloudflare

Oder das Docker-Image mit Modulen verwenden:

services:
  caddy:
    image: caddy:2-builder AS builder
    # Multi-Stage oder vorgefertigtes benutzerdefiniertes Image verwenden

Statische Dateien + API

SPA mit API-Backend

domain.com {
    handle /api/* {
        reverse_proxy localhost:8080
    }

    handle {
        root * /srv/frontend
        try_files {path} /index.html
        file_server
    }
}

Statische Dateien bereitstellen + Proxy

domain.com {
    root * /var/www/html
    file_server

    handle /app/* {
        reverse_proxy localhost:3000
    }
}

WebSocket-Unterstuetzung

Caddy leitet WebSocket-Verbindungen automatisch weiter:

ws.domain.com {
    reverse_proxy localhost:8080
}

Keine zusaetzliche Konfiguration erforderlich. Caddy erkennt den Upgrade-Header und verarbeitet ihn.

Protokollierung

Zugriffsprotokolle

domain.com {
    log {
        output file /var/log/caddy/access.log {
            roll_size 100mb
            roll_keep 5
        }
        format json
    }
    reverse_proxy localhost:3000
}

Protokollierung pro Website

app.domain.com {
    log {
        output file /var/log/caddy/app.log
    }
    reverse_proxy localhost:3000
}

api.domain.com {
    log {
        output file /var/log/caddy/api.log
    }
    reverse_proxy localhost:8080
}

Komprimierung

domain.com {
    encode gzip zstd
    reverse_proxy localhost:3000
}

Caddy unterstuetzt sowohl gzip- als auch Zstandard-Komprimierung direkt nach der Installation.

CORS-Header

api.domain.com {
    header Access-Control-Allow-Origin "https://app.domain.com"
    header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
    header Access-Control-Allow-Headers "Content-Type, Authorization"

    @options method OPTIONS
    respond @options 204

    reverse_proxy localhost:8080
}

Weiterleitungen

WWW zu Apex

www.domain.com {
    redir https://domain.com{uri} permanent
}

domain.com {
    reverse_proxy localhost:3000
}

HTTP zu HTTPS

Caddy macht das automatisch. Keine Konfiguration erforderlich.

Benutzerdefinierte Weiterleitungen

domain.com {
    redir /old-page /new-page permanent
    redir /blog/* /articles/{re.1} permanent
    reverse_proxy localhost:3000
}

Caching

domain.com {
    header /static/* Cache-Control "public, max-age=31536000, immutable"
    header /api/* Cache-Control "no-cache"
    reverse_proxy localhost:3000
}

Konfiguration ueber API

Caddy verfuegt ueber eine vollstaendige REST-API fuer Konfigurationsaenderungen:

# Aktuelle Konfiguration abrufen
curl localhost:2019/config/

# Eine Route aktualisieren
curl localhost:2019/config/apps/http/servers/srv0/routes/0 \
  -X PUT \
  -H "Content-Type: application/json" \
  -d '{"handle": [{"handler": "reverse_proxy", "upstreams": [{"dial": "localhost:3001"}]}]}'

# Aus Caddyfile neu laden
caddy reload --config /etc/caddy/Caddyfile

Fehlerbehebung

Zertifikat wird nicht ausgestellt

  1. Pruefen Sie, ob DNS auf Ihren VPS zeigt:
dig +short domain.com
  1. Stellen Sie sicher, dass die Ports 80 und 443 geoeffnet sind:
sudo ufw allow 80,443/tcp
  1. Caddy-Protokolle pruefen:
journalctl -u caddy --no-pager -n 50
# Oder fuer Docker:
docker logs caddy

502 Bad Gateway

  1. Ueberpruefen Sie, ob das Backend laeuft:
curl localhost:3000
  1. Pruefen Sie die Upstream-Adresse im Caddyfile

  2. Bei Docker: Stellen Sie sicher, dass beide Container im selben Netzwerk sind

Konfigurationssyntaxfehler

caddy validate --config /etc/caddy/Caddyfile

Langsame Leistung

  1. Komprimierung aktivieren:
encode gzip zstd
  1. Backend-Antwortzeiten pruefen

  2. Verbindungstimeouts hinzufuegen:

reverse_proxy localhost:3000 {
    transport http {
        dial_timeout 5s
        response_header_timeout 10s
    }
}

Produktions-Checkliste

Bester VPS fuer Caddy

Caddy laeuft ueberall. Waehlen Sie Ihren VPS basierend auf Ihren Backend-Anforderungen:

AnbieterPlanPreisAm besten fuer
HostingerKVM1$4.99Bestes Preis-Leistungs-Verhaeltnis fuer Einsteiger
HetznerCX22€5.49Europa-basierte Projekte
DigitalOceanBasic$6Entwicklerfreundlich
VultrVC2$6Globale Edge-Standorte

Hostinger bietet das beste Preis-Leistungs-Verhaeltnis, wenn Sie gerade anfangen. Deren KVM1-Plan bewaeligt Caddy plus mehrere Backend-Dienste problemlos.

FAQ

Ist Caddy produktionsreif?

Absolut. Caddy v2 betreibt Tausende von Produktionswebsites. Es wird von Unternehmen jeder Groesse eingesetzt.

Caddy vs Nginx als Reverse Proxy?

Caddy fuer Einfachheit und automatisches HTTPS. Nginx fuer maximale Kontrolle und Legacy-Konfigurationen. Fuer die meisten neuen Bereitstellungen spart Caddy Stunden an Einrichtungszeit.

Wie funktioniert automatisches HTTPS?

Caddy verwendet das ACME-Protokoll, um Zertifikate von Let’s Encrypt (oder ZeroSSL) zu erhalten. Es uebernimmt Ausstellung, Erneuerung und OCSP-Stapling automatisch.

Kann Caddy Apache ersetzen?

Ja. Caddy bewaeligt alles, was Apache fuer moderne Webbereitstellungen tut, mit einem Bruchteil der Konfiguration.

Unterstuetzt Caddy HTTP/3?

Ja, HTTP/3 (QUIC) ist standardmaeßig auf dem HTTPS-Port aktiviert.

Wie aktualisiere ich Caddy?

Paketmanager: apt upgrade caddy. Docker: Neues Image pullen. Binaerdatei: Herunterladen und ersetzen.

Zusammenfassung

Caddy macht Reverse-Proxying einfach:

AufgabeNginxCaddy
SSL erhaltenCertbot installieren, konfigurierenAutomatisch
Dienst hinzufuegenKonfig bearbeiten, testen, neu laden3 Zeilen hinzufuegen, neu laden
HTTP→HTTPS umleitenServer-Block hinzufuegenAutomatisch
HTTP/2 aktivierenKonfigurierenAutomatisch
KonfigurationssyntaxKomplexMenschenlesbar

Drei Zeilen in einem Caddyfile ersetzen Dutzende in der Nginx-Konfiguration. Fuer neue Projekte ist Caddy der schnellste Weg zu einem sicheren, produktionsreifen Reverse Proxy. Kombinieren Sie es mit Docker Compose fuer einen kompletten Bereitstellungs-Workflow, oder lesen Sie unsere VPS-Haertungsanleitung, um den Rest Ihres Servers abzusichern.

~/caddy-reverse-proxy-guide/get-started

Ready to get started?

Get the best VPS hosting deal today. Hostinger offers 4GB RAM VPS starting at just $4.99/mo.

Get Hostinger VPS — $4.99/mo

// up to 75% off + free domain included

// related topics

caddy reverse proxy caddy server einrichten caddy ssl caddy docker caddy vs nginx

// related guides

Andrius Putna

Andrius Putna

I am Andrius Putna. Geek. Since early 2000 in love tinkering with web technologies. Now AI. Bridging business and technology to drive meaningful impact. Combining expertise in customer experience, technology, and business strategy to deliver valuable insights. Father, open-source contributor, investor, 2xIronman, MBA graduate.

// last updated: March 11, 2026. Disclosure: This article may contain affiliate links.