Files
git-pages/conf/Caddyfile
Catherine a159dba0b8 [breaking-change] Redesign environment var configuration overrides.
This is done using reflection to avoid boilerplate and potential desync
of the two configuration interfaces. The `[[wildcards]]` section did
not fit well into the "splat every config key" paradigm, so it is
unmarshalled as a whole from a JSON payload in an environment variable.

This commit also splits up the `Config` type into small per-section
struct types and removes most references to the global `config` in
favor of passing pointers to sections around.

A new option, `-print-config-env-vars`, shows the names and types of
all of the available configuration knobs.
2025-09-22 07:02:42 +00:00

101 lines
1.4 KiB
Caddyfile

(proxy) {
listener_wrappers {
proxy_protocol {
timeout 1s
allow {$ALLOW_PROXY}
}
tls
}
}
{
persist_config off
log {
output stderr
level WARN
exclude http.auto_https
format console {
time_key ""
}
}
metrics {
per_host
}
storage s3 {
host "{env.PAGES_STORAGE_S3_ENDPOINT}"
access_id "{env.PAGES_STORAGE_S3_ACCESS_KEY_ID}"
secret_key "{env.PAGES_STORAGE_S3_SECRET_ACCESS_KEY}"
bucket "{env.PAGES_STORAGE_S3_BUCKET}"
prefix "ssl"
}
email {env.ACME_EMAIL}
auto_https disable_redirects
on_demand_tls {
permission http http://localhost:3001
}
servers :80 {
name http
protocols h1 h2c
import proxy
}
servers :443 {
name https
protocols h1 h2
import proxy
}
servers {$UDP_BIND_TO:0.0.0.0}:443 {
name http3
protocols h3
}
servers :2002 {
name health
protocols h1
}
}
(backend) {
tls {
on_demand
}
@h2c `{env.PAGES_FEATURES}.matches(r"\bh2c\b")`
reverse_proxy @h2c h2c://{$GIT_PAGES_ADDRESS:localhost}:3000
reverse_proxy http://{$GIT_PAGES_ADDRESS:localhost}:3000
header Alt-Svc `h3=":443"; persist=1, h2=":443"; persist=1`
encode
}
http:// {
# initial PUT/POST for a new domain has to happen over HTTP
@get method GET
redir @get https://{host}{uri} 301
import backend
}
https:// {
import backend
}
https:// {
# Fly.io requires UDP sockets to be bound to a different IP
bind {$UDP_BIND_TO:0.0.0.0}
import backend
}
http://localhost:2002 {
reverse_proxy http://localhost:3002
}