Caddyfile
# Caddyfile — smarthub.my
# Optimized for 6 cores / 32GB RAM
# Caddy only — never nginx, never Apache
smarthub.my {
# --- COMPRESSION ---
encode zstd gzip
# --- WIKI API (FastAPI/uvicorn on port 8000) ---
@api path /wiki/api/*
reverse_proxy @api localhost:8000 {
lb_policy round_robin
health_uri /wiki/api/health
health_interval 30s
header_up X-Real-IP {remote_host}
}
# --- WIKI STATIC SITE ---
@wiki path /wiki/*
handle @wiki {
root * /var/www/smarthub.my
file_server {
hide .git
}
header Cache-Control "public, max-age=3600, must-revalidate"
header X-Content-Type-Options nosniff
header X-Frame-Options DENY
}
# --- ROOT ---
handle {
root * /var/www/smarthub.my
file_server
header Cache-Control "public, max-age=300"
}
# --- LOGGING ---
log {
output file /var/log/caddy/smarthub.log {
roll_size 100mb
roll_keep 5
}
format json
}
# TLS handled automatically by Caddy (Let's Encrypt)
}