Caddy Server: современный веб-сервер
Caddy автоматически получает и обновляет SSL-сертификаты через Let's Encrypt без какой-либо ручной настройки. Это главное преимущество перед Nginx — не нужен Certbot.
Установка на Ubuntu/Debian
apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
apt update && apt install caddyБазовая конфигурация (Caddyfile)
# /etc/caddy/Caddyfile
yourdomain.com {
root * /var/www/html
file_server
encode gzip
}
api.yourdomain.com {
reverse_proxy localhost:3000
}PHP-FPM с Caddy
yourdomain.com {
root * /var/www/html
encode gzip
php_fastcgi unix//run/php/php8.3-fpm.sock
file_server
try_files {path} {path}/ /index.php?{query}
}Заголовки безопасности
yourdomain.com {
root * /var/www/html
file_server
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains"
X-Content-Type-Options nosniff
X-Frame-Options DENY
-Server
}
}Балансировка нагрузки
yourdomain.com {
reverse_proxy {
to localhost:8001 localhost:8002 localhost:8003
lb_policy round_robin
health_uri /ping
health_interval 15s
}
}Управление сервисом
systemctl reload caddy
caddy validate --config /etc/caddy/Caddyfile
caddy fmt --overwrite /etc/caddy/CaddyfileHTTP/3: Caddy включает HTTP/3 (QUIC) по умолчанию — ускоряет загрузку на мобильных сетях. Убедитесь, что порт UDP 443 открыт в firewall.