Closed crysper closed 1 year ago
Can you elaborate more? Do you use JSON Configuration, Caddyfile, or ENV variables? How do you write it?
On Sat, Dec 12, 2020 at 5:53 PM crysper notifications@github.com wrote:
Hey,
If I'm putting something like this on the JSON config file instead of using Caddyfile and the variables are not parsed even though in other parts of the config are parsed ok.
I get this error: `"logger":"caddy.storage.redis","msg":"TLS Storage are using Redis, on {env.REDIS_HOST}:6379"}
I'm using Caddy version 2.2.2 `
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gamalan/caddy-tlsredis/issues/21, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIYFE4OLBMTL6C4BMSOQR3SUNDS7ANCNFSM4UX74STQ .
Same on my side, I use json configuration, and {env.VAR_NAME}, caddy support this syntax to pass ENV variables to config. But it don`t work in storage part of config
@gamalan Supporting placeholders in provisioning is pretty easy fortunately! You just need to call caddy.NewReplacer()
and then call one of the Replace*
methods, like ReplaceAll()
, ReplaceKnown()
, or ReplaceOrErr()
, for example:
Then users can specify environment variables (or other placeholders) in your config values. :)
@TekVanDo can you post your config and logs?
Config
{ "apps": { "http": { "servers": { "myserver": { "listen": [ ":8080" ], "logs": {}, "routes": [ { "handle": [ { "handler": "reverse_proxy", "upstreams": [ { "dial": "{env.REDIRECT_ADDRESS}" } ] } ] } ] } } }, "tls": { "automation": { "on_demand": { "ask": "{env.SITE_ADDRESS}/proxyCheck" }, "policies": [ { "issuers": [ { "module": "acme", "email": "${env.EMAIL}" } ], "on_demand": true } ] } } }, "storage": { "address": "{env.REDIS_ADDRESS}", "db": 0, "host": "redis", "key_prefix": "{env.REDIS_KEY_PREFIX}", "module": "redis", "password": "", "port": "{env.REDIS_PORT}", "value_prefix": "{env.REDIS_VALUE_PREFIX}" } }
And i got an error is - "run: loading initial config: loading new config: loading storage module: loading module 'redis': provision caddy.storage.redis: dial tcp: address {env.REDIS_ADDRESS}: missing port in address"
if I change {env.REDIS_ADDRESS} to ENV variable value (ip + port) all works fine.
@TekVanDo @crysper can you test the new release (v0.2.9)?
@gamalan. Sorry i just double checked it. I steel got an error
run: loading initial config: loading new config: loading storage module: loading module 'redis': provision caddy.storage.redis: dial tcp: address {env.REDIS_ADDRESS}: missing port in address
@gamalan seems fix don`t helped(
@TekVanDo you shouldn't use address, but split it in host and port
Hey,
If I'm putting something like this on the JSON config file instead of using Caddyfile the variables are not parsed even though in other parts of the config are parsed ok.
I get this error: `"logger":"caddy.storage.redis","msg":"TLS Storage are using Redis, on {env.REDIS_HOST}:6379"}
I'm using Caddy version 2.2.2 Running on systemctl service with: ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/caddyfile.json `