caddy: Env var for domain names not supported?
Hello! First of all, thanks so much for Caddy… it has been a lifesaver 😃
1. Which version of Caddy are you using (caddy -version)?
Caddy 0.11.5 (unofficial)
2. What are you trying to do?
Pass {$CADDY_DOMAIN} to our Caddyfile for multiple domains
3. What is your Caddyfile?
paste entire Caddyfile here - DO NOT REDACT ANYTHING (except credentials)
{$CADDY_DOMAIN} {
gzip
root /var/www/testing
proxy / web:8000 {
transparent
except /static
}
push
}
The above fails the following ways with the following inputs:
# CADDY_DOMAIN=http://localhost, https://testing.serveo.net
2019/06/03 17:33:52 error inspecting server blocks: parse http://localhost, https://testing.serveo.net: invalid character " " in host name
# CADDY_DOMAIN=http://localhost,https://testing.serveo.net
2019/06/03 17:41:17 [INFO] Serving http://localhost,https//testing.serveo.net
# (note the domain is wrong, smashed both together)
However when I put the text straight in the Caddyfile, it works!
# This works!
http://localhost,https://testing.serveo.net {
gzip
root /var/www/testing
proxy / web:8000 {
transparent
except /static
}
push
}
4. How did you run Caddy (give the full command and describe the execution environment)?
From a docker container, defined like so…
caddy:
image: abiosoft/caddy:latest
restart: unless-stopped
env_file: .env
volumes:
- ./conf/Caddyfile:/etc/Caddyfile
- ./testing/static:/var/www/testing/static
- ./docker_storage/certs/caddy:/etc/caddycerts
ports:
- 80:2015
- 443:443
depends_on:
- web
Bonus: What do you use Caddy for? Why did you choose Caddy?
For the easy HTTP/2 and SSL 😃
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 16 (8 by maintainers)
Ah, yeah, in that case then seems like 2 birds with one stone 😃
In any event, we’ve worked around this “problem” and love using Caddy, thanks so much! Excited to try out v2.
The Caddyfile parser doesn’t expand one variable into more than one token - if you need more than one domain, put two env vars in your Caddyfile and set each of them.
Hey @mholt ! First of all thank you for making ssl so easy. I spent hours working out automated process with openresty, lua scripts, bash scripts, stack overflow and too much coffee.
I do see this issue got closed with a remark that Caddy 2.0 will just work but I tested and if I set
CADDY_DOMAIN=domain.one, domain.twoit doesn’t expand{$CADDY_DOMAIN}in Caddyfile properly. It works for just one domain and it does work when I put the domain names there manually. My use case is that I do have multiple servers that host the same site behind the load balancer but any specific server is also accessible through each server’s subdomain so I need bothexample.comandfoo.example.comassigned to one block in Caddyfile. I am fine doing it manually but env variable does sound super awesome and flexible.