Caddy Reverse Proxy Handleiding 2026: Automatische HTTPS Eenvoudig Gemaakt
Stel Caddy in als reverse proxy met automatische HTTPS, zero-config SSL en eenvoudige Caddyfile-syntax. Complete VPS-implementatiehandleiding.
Caddy Reverse Proxy Handleiding: Automatische HTTPS Eenvoudig Gemaakt
Caddy is de webserver die standaard HTTPS gebruikt. Geen certbot, geen cron-taken, geen verlengingsscripts. Wijs een domein naar Caddy en het krijgt automatisch een certificaat.
Wat is Caddy?
Caddy zit tussen het internet en je services:
Internet → Caddy → Service A (app.domain.com)
→ Service B (api.domain.com)
→ Service C (admin.domain.com)
Waarom ontwikkelaars van Caddy houden:
- Automatische HTTPS — SSL-certificaten zonder configuratie
- Eenvoudige configuratie — De Caddyfile is leesbaar voor mensen
- HTTP/2 en HTTP/3 — Standaard ingeschakeld
- Enkele binary — Geen afhankelijkheden
- API-gestuurd — Configuratie wijzigen zonder herstarten
Caddy vs Nginx vs Traefik
| Functie | Caddy | Nginx | Traefik |
|---|---|---|---|
| Auto HTTPS | Standaard | Certbot nodig | Ingebouwd |
| Configuratiesyntax | Eenvoudig | Gemiddeld | Complex |
| Docker-integratie | Goed | Handmatig | Native |
| Prestaties | Uitstekend | Uitstekend | Uitstekend |
| Plugins | Go modules | C modules | Middleware |
| Config herladen | Zero-downtime | Vereist signaal | Hot reload |
| Leercurve | Laag | Gemiddeld | Hoger |
Caddy wint op eenvoud. Als je de makkelijkste reverse proxy-setup wilt, is dit het. Bekijk onze Traefik Docker handleiding voor container-native routing.
VPS-vereisten
Caddy is extreem lichtgewicht:
- 1 vCPU
- 256MB RAM (voor Caddy zelf)
- Poorten 80, 443
- Een domeinnaam die naar je VPS wijst
De grootte van je VPS hangt af van je backend-services, niet van Caddy. Bekijk onze beste VPS voor Docker handleiding voor aanbevelingen qua dimensionering.
Caddy installeren
Optie 1: Pakketbeheerder (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
Optie 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:
Optie 3: Enkele Binary
curl -sS https://webi.sh/caddy | sh
Basis Reverse Proxy
De Eenvoudigste Caddyfile
app.domain.com {
reverse_proxy localhost:3000
}
Dat is alles. Caddy zal:
- Luisteren op poorten 80 en 443
- Een SSL-certificaat ophalen bij Let’s Encrypt
- HTTP omleiden naar HTTPS
- Verkeer doorsturen naar je app op poort 3000
Meerdere Services
app.domain.com {
reverse_proxy localhost:3000
}
api.domain.com {
reverse_proxy localhost:8080
}
admin.domain.com {
reverse_proxy localhost:9000
}
Elk domein krijgt automatisch zijn eigen certificaat.
Docker Reverse Proxy Setup
Stap 1: Projectmap aanmaken
mkdir -p /opt/caddy
cd /opt/caddy
Stap 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:
Stap 3: Caddyfile
test.domain.com {
reverse_proxy whoami:80
}
Stap 4: Starten
docker compose up -d
Bezoek https://test.domain.com — het werkt met volledige HTTPS.
Extra Docker Services Toevoegen
Elke service op het caddy-netwerk kan worden geproxied:
# apart docker-compose.yml
services:
myapp:
image: myapp:latest
container_name: myapp
networks:
- caddy
networks:
caddy:
external: true
Voeg dan toe aan je Caddyfile:
myapp.domain.com {
reverse_proxy myapp:8080
}
Herlaad Caddy:
docker exec caddy caddy reload --config /etc/caddy/Caddyfile
Pad-gebaseerde Routing
Routeren op Pad
domain.com {
handle /api/* {
reverse_proxy localhost:8080
}
handle /admin/* {
reverse_proxy localhost:9000
}
handle {
reverse_proxy localhost:3000
}
}
Padprefix Verwijderen
domain.com {
handle_path /api/* {
reverse_proxy localhost:8080
}
}
handle_path verwijdert het overeenkomende prefix. /api/users wordt /users voor de backend.
Load Balancing
Round Robin (Standaard)
app.domain.com {
reverse_proxy app1:3000 app2:3000 app3:3000
}
Met Gezondheidscontroles
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
}
}
Minste Verbindingen
app.domain.com {
reverse_proxy app1:3000 app2:3000 {
lb_policy least_conn
}
}
Beveiliging
Basisauthenticatie
# Wachtwoordhash genereren
caddy hash-password --plaintext 'your-secure-password'
admin.domain.com {
basicauth {
admin $2a$14$Zkx19...hashed...password
}
reverse_proxy localhost:9000
}
IP-toelatingslijst
admin.domain.com {
@blocked not remote_ip 192.168.1.0/24 10.0.0.0/8
respond @blocked 403
reverse_proxy localhost:9000
}
Snelheidsbeperking
api.domain.com {
rate_limit {
zone dynamic {
key {remote_host}
events 100
window 1m
}
}
reverse_proxy localhost:8080
}
Beveiligingsheaders
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
}
De -Server-richtlijn verwijdert de Server-header uit responses.
Wildcard-certificaten
Voor *.domain.com, gebruik 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
}
}
Bouw Caddy met de Cloudflare DNS-module:
xcaddy build --with github.com/caddy-dns/cloudflare
Of gebruik de Docker-image met modules:
services:
caddy:
image: caddy:2-builder AS builder
# Gebruik multi-stage of vooraf gebouwde aangepaste image
Statische Bestanden + API
SPA met API Backend
domain.com {
handle /api/* {
reverse_proxy localhost:8080
}
handle {
root * /srv/frontend
try_files {path} /index.html
file_server
}
}
Statisch Serveren + Proxy
domain.com {
root * /var/www/html
file_server
handle /app/* {
reverse_proxy localhost:3000
}
}
WebSocket-ondersteuning
Caddy proxied WebSocket-verbindingen automatisch:
ws.domain.com {
reverse_proxy localhost:8080
}
Geen extra configuratie nodig. Caddy detecteert de Upgrade-header en handelt deze af.
Logging
Toegangslogs
domain.com {
log {
output file /var/log/caddy/access.log {
roll_size 100mb
roll_keep 5
}
format json
}
reverse_proxy localhost:3000
}
Logging per Site
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
}
Compressie
domain.com {
encode gzip zstd
reverse_proxy localhost:3000
}
Caddy ondersteunt standaard zowel gzip- als Zstandard-compressie.
CORS-headers
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
}
Omleidingen
WWW naar Apex
www.domain.com {
redir https://domain.com{uri} permanent
}
domain.com {
reverse_proxy localhost:3000
}
HTTP naar HTTPS
Caddy doet dit automatisch. Geen configuratie nodig.
Aangepaste Omleidingen
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
}
Configuratie via API
Caddy heeft een volledige REST API voor configuratiewijzigingen:
# Huidige configuratie ophalen
curl localhost:2019/config/
# Een route bijwerken
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"}]}]}'
# Herladen vanuit Caddyfile
caddy reload --config /etc/caddy/Caddyfile
Probleemoplossing
Certificaat Niet Uitgegeven
- Controleer of DNS naar je VPS wijst:
dig +short domain.com
- Zorg ervoor dat poorten 80 en 443 open zijn:
sudo ufw allow 80,443/tcp
- Controleer Caddy-logs:
journalctl -u caddy --no-pager -n 50
# Of voor Docker:
docker logs caddy
502 Bad Gateway
- Controleer of de backend draait:
curl localhost:3000
-
Controleer het upstream-adres in de Caddyfile
-
Voor Docker: zorg ervoor dat beide containers op hetzelfde netwerk zitten
Configuratiesyntaxfout
caddy validate --config /etc/caddy/Caddyfile
Trage Prestaties
- Schakel compressie in:
encode gzip zstd
-
Controleer de responstijden van de backend
-
Voeg verbindingstime-outs toe:
reverse_proxy localhost:3000 {
transport http {
dial_timeout 5s
response_header_timeout 10s
}
}
Productiechecklist
- DNS-records wijzen naar VPS
- Firewall staat poorten 80, 443 toe
- Caddyfile gevalideerd (
caddy validate) - Toegangslogs ingeschakeld
- Beveiligingsheaders geconfigureerd
- Backend-gezondheidscontroles ingesteld
- Compressie ingeschakeld
- Back-up van
/data-map (certificaten)
Beste VPS voor Caddy
Caddy draait overal. Kies je VPS op basis van je backend-behoeften:
| Provider | Plan | Prijs | Beste Voor |
|---|---|---|---|
| Hostinger | KVM1 | $4,99 | Beste waarde voor beginners |
| Hetzner | CX22 | €5,49 | Projecten in Europa |
| DigitalOcean | Basic | $6 | Ontwikkelaarsvriendelijk |
| Vultr | VC2 | $6 | Wereldwijde edge-locaties |
Hostinger biedt de beste prijs-kwaliteitverhouding als je net begint. Hun KVM1-plan verwerkt Caddy plus meerdere backend-services comfortabel.
FAQ
Is Caddy klaar voor productie?
Absoluut. Caddy v2 drijft duizenden productiesites aan. Het wordt gebruikt door bedrijven van alle groottes.
Caddy vs Nginx voor reverse proxy?
Caddy voor eenvoud en automatische HTTPS. Nginx voor maximale controle en legacy-configuraties. Voor de meeste nieuwe implementaties bespaart Caddy uren aan installatietijd.
Hoe werkt automatische HTTPS?
Caddy gebruikt het ACME-protocol om certificaten te verkrijgen van Let’s Encrypt (of ZeroSSL). Het regelt uitgifte, verlenging en OCSP-stapling automatisch.
Kan Caddy Apache vervangen?
Ja. Caddy doet alles wat Apache doet voor moderne webimplementaties, met een fractie van de configuratie.
Ondersteunt Caddy HTTP/3?
Ja, HTTP/3 (QUIC) is standaard ingeschakeld op de HTTPS-poort.
Hoe werk ik Caddy bij?
Pakketbeheerder: apt upgrade caddy. Docker: pull de nieuwe image. Binary: download en vervang.
Samenvatting
Caddy maakt reverse proxying eenvoudig:
| Taak | Nginx | Caddy |
|---|---|---|
| SSL verkrijgen | Certbot installeren, configureren | Automatisch |
| Service toevoegen | Config bewerken, testen, herladen | 3 regels toevoegen, herladen |
| HTTP→HTTPS omleiden | Serverblok toevoegen | Automatisch |
| HTTP/2 inschakelen | Configureren | Automatisch |
| Configuratiesyntax | Complex | Leesbaar voor mensen |
Drie regels in een Caddyfile vervangen tientallen in Nginx-configuratie. Voor nieuwe projecten is Caddy het snelste pad naar een veilige, productieklare reverse proxy. Combineer het met Docker Compose voor een complete implementatieworkflow, of bekijk onze VPS-beveiligingshandleiding om de rest van je server te beveiligen.
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
// related guides
$1 VPS Hosting 2026: Cheapest VPS Servers Starting at $1/Month
Looking for $1 VPS hosting? Compare the cheapest VPS providers starting from $1-3/month. Real specs, no hidden fees, honest reviews of budget VPS options.
tutorialCloudflare Tunnel VPS Guide 2026: Expose Services Without Opening Ports
Set up Cloudflare Tunnel on your VPS to expose web apps securely without opening ports or revealing your server IP. Complete guide with Docker and DNS config.
tutorialCoolify VPS Setup Guide 2026: Self-Hosted Vercel Alternative
Deploy Coolify on your VPS for a self-hosted Vercel/Netlify experience. Complete setup guide with Docker, SSL, and app deployments.
tutorialVPS with Crypto & No KYC — 7 Providers That Accept Bitcoin
Pay for VPS hosting with Bitcoin, Monero, or ETH — no ID required. We list 7 privacy-first providers with anonymous signup. Updated March 2026.
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.