You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to build a Caddy configuration that can cater to multiple environments (production, staging, local development).
To achieve this, I want to use environment variables for the base host names/urls, via the {env.*} placeholder. This works great in addresses, route matches and upstream reverse-proxy configuration.
Unfortunately, using the same approach does currently not work when using On-Demand-TLS with the ask property because the placeholder is not replaced at runtime:
2020/12/14 21:49:44.939 DEBUG http.stdlib http: TLS handshake error from [::1]:62116: parsing ask URL: parse "http://{env.API_HOST}/domain-check": invalid character "{" in host name
You should instead be using the {$ENV} style environment variables. Those are replaced at Caddyfile-parse time, but {env.ENV} style are replaced at runtime.
@francislavoie Thanks for the tip! I really did miss the point regarding the variable replacement at parse time vs runtime. Everything works now as expected.
Would you like to keep this issue open for the JSON config users?
I am trying to build a Caddy configuration that can cater to multiple environments (production, staging, local development).
To achieve this, I want to use environment variables for the base host names/urls, via the
{env.*}
placeholder. This works great in addresses, route matches and upstream reverse-proxy configuration.Unfortunately, using the same approach does currently not work when using On-Demand-TLS with the
ask
property because the placeholder is not replaced at runtime:Here's the relevant part of the config:
The text was updated successfully, but these errors were encountered: