Web / Caddy Server Interview questions
How do you use environment variable placeholders in a Caddyfile?
The {env.VAR_NAME} placeholder pulls a value from the environment Caddy is running in, letting the same Caddyfile adapt to different environments without editing it.
{ email {env.ACME_EMAIL} } {$SITE_DOMAIN} { reverse_proxy {$BACKEND_HOST}:{$BACKEND_PORT} }
Inside directive arguments, {env.NAME} is the explicit form, while the shorthand {$NAME} works in most places including site addresses, as shown for {$SITE_DOMAIN} above. This is the standard way to keep secrets like ACME account emails or backend hostnames out of the Caddyfile itself, sourcing them instead from systemd environment files, Docker Compose, or a secrets manager.
More Related questions...