ยง2023-07-07
Caddy directives are configuration instructions used in the Caddy web server to define how it should handle incoming requests and serve content. In Caddy, the server configuration is typically written in a Caddyfile, which is a plain text file containing a series of directives. Each directive represents a specific action or behavior that Caddy should take for a particular set of requests. Directives are structured in a block format, where each block begins with a keyword followed by its parameters and an associated block of subdirectives.
- Caddyfile
example.com {
# ssl certificate from cerbot
# tls /etc/letsencrypt/live/h2jammy.yushei.net/fullchain.pem /etc/letsencrypt/live/h2jammy.yushei.net/privkey.pem
tls /etc/caddy/fullchain.pem /etc/caddy/privkey.pem
root /var/www/html
encode gzip
log {
output file ./access.log
}
proxy /api localhost:3000 {
# will retain the original Host header
transparent
}
tls {
dns cloudflare
}
}