Caddyfile language preview
1. Reverse proxy site
site addresses, directives, and placeholders
horizon-dark
example.com {
encode gzip
reverse_proxy localhost:8080 {
header_up X-Real-IP {remote_host}
}
log {
output file /var/log/caddy/access.log
}
} atom-one-dark
example.com {
encode gzip
reverse_proxy localhost:8080 {
header_up X-Real-IP {remote_host}
}
log {
output file /var/log/caddy/access.log
}
} github-dark
example.com {
encode gzip
reverse_proxy localhost:8080 {
header_up X-Real-IP {remote_host}
}
log {
output file /var/log/caddy/access.log
}
} dracula
example.com {
encode gzip
reverse_proxy localhost:8080 {
header_up X-Real-IP {remote_host}
}
log {
output file /var/log/caddy/access.log
}
} nord
example.com {
encode gzip
reverse_proxy localhost:8080 {
header_up X-Real-IP {remote_host}
}
log {
output file /var/log/caddy/access.log
}
} github
example.com {
encode gzip
reverse_proxy localhost:8080 {
header_up X-Real-IP {remote_host}
}
log {
output file /var/log/caddy/access.log
}
} 2. Multiple addresses on one site block
one site header covering several hostnames
horizon-dark
www.example.com example.com {
redir https://example.com{uri} permanent
} atom-one-dark
www.example.com example.com {
redir https://example.com{uri} permanent
} github-dark
www.example.com example.com {
redir https://example.com{uri} permanent
} dracula
www.example.com example.com {
redir https://example.com{uri} permanent
} nord
www.example.com example.com {
redir https://example.com{uri} permanent
} github
www.example.com example.com {
redir https://example.com{uri} permanent
} 3. Matchers and static files
named matchers, snippets, and file serving
horizon-dark
# shared TLS config
(tls_config) {
tls admin@example.com
}
static.example.com {
import tls_config
root * /srv/www
@assets path /static/*
handle @assets {
file_server
}
} atom-one-dark
# shared TLS config
(tls_config) {
tls admin@example.com
}
static.example.com {
import tls_config
root * /srv/www
@assets path /static/*
handle @assets {
file_server
}
} github-dark
# shared TLS config
(tls_config) {
tls admin@example.com
}
static.example.com {
import tls_config
root * /srv/www
@assets path /static/*
handle @assets {
file_server
}
} dracula
# shared TLS config
(tls_config) {
tls admin@example.com
}
static.example.com {
import tls_config
root * /srv/www
@assets path /static/*
handle @assets {
file_server
}
} nord
# shared TLS config
(tls_config) {
tls admin@example.com
}
static.example.com {
import tls_config
root * /srv/www
@assets path /static/*
handle @assets {
file_server
}
} github
# shared TLS config
(tls_config) {
tls admin@example.com
}
static.example.com {
import tls_config
root * /srv/www
@assets path /static/*
handle @assets {
file_server
}
} 4. Load-balanced upstream with TLS options
to, lb_policy, health_uri, protocols, and ciphers
horizon-dark
api.example.com {
reverse_proxy {
to backend1:8080 backend2:8080
lb_policy round_robin
health_uri /health
}
tls {
protocols tls1.2 tls1.3
ciphers TLS_AES_256_GCM_SHA384
}
} atom-one-dark
api.example.com {
reverse_proxy {
to backend1:8080 backend2:8080
lb_policy round_robin
health_uri /health
}
tls {
protocols tls1.2 tls1.3
ciphers TLS_AES_256_GCM_SHA384
}
} github-dark
api.example.com {
reverse_proxy {
to backend1:8080 backend2:8080
lb_policy round_robin
health_uri /health
}
tls {
protocols tls1.2 tls1.3
ciphers TLS_AES_256_GCM_SHA384
}
} dracula
api.example.com {
reverse_proxy {
to backend1:8080 backend2:8080
lb_policy round_robin
health_uri /health
}
tls {
protocols tls1.2 tls1.3
ciphers TLS_AES_256_GCM_SHA384
}
} nord
api.example.com {
reverse_proxy {
to backend1:8080 backend2:8080
lb_policy round_robin
health_uri /health
}
tls {
protocols tls1.2 tls1.3
ciphers TLS_AES_256_GCM_SHA384
}
} github
api.example.com {
reverse_proxy {
to backend1:8080 backend2:8080
lb_policy round_robin
health_uri /health
}
tls {
protocols tls1.2 tls1.3
ciphers TLS_AES_256_GCM_SHA384
}
}