@marcel91200 / caddy Mirror · read-only / commits / 61642b76
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

caddytls: Run replacer on ask URL, for env vars (#4154)

Fixes #3922

Francis Lavoie committed May 9, 2021 at 00:37 UTC 61642b766baaa8cef62f5a7ea3c29d8ebdbd86ea
1 file changed +6
modules/caddytls/tls.go
+6
@@ -87,6 +87,7 @@ func (TLS) CaddyModule() caddy.ModuleInfo {
87 func (t *TLS) Provision(ctx caddy.Context) error {
88 t.ctx = ctx
89 t.logger = ctx.Logger(t)
90 + repl := caddy.NewReplacer()
91
92 // set up a new certificate cache; this (re)loads all certificates
93 cacheOpts := certmagic.CacheOptions{
@@ -176,6 +177,11 @@ func (t *TLS) Provision(ctx caddy.Context) error {
177 onDemandRateLimiter.SetWindow(0)
178 }
179
180 + // run replacer on ask URL (for environment variables)
181 + if t.Automation != nil && t.Automation.OnDemand != nil && t.Automation.OnDemand.Ask != "" {
182 + t.Automation.OnDemand.Ask = repl.ReplaceAll(t.Automation.OnDemand.Ask, "")
183 + }
184 +
185 // load manual/static (unmanaged) certificates - we do this in
186 // provision so that other apps (such as http) can know which
187 // certificates have been manually loaded, and also so that