Caddy: in Caddyfile when using {env.MY_DOMAIN} it searches for lower case my_domain

Created on 14 Apr 2020  路  4Comments  路  Source: caddyserver/caddy

docker-compose.yml

version: "3.7"

services:
  caddy:
    image: "caddy/caddy"
    container_name: "caddy"
    hostname: "caddy"
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - ./data:/data
      - ./config:/config
    environment:
      - MY_DOMAIN=blabla.org

Caddyfile

book.{env.MY_DOMAIN} {
    reverse_proxy bookstack:80
}

evaluated placeholder {env.my_domain} is empty

printenv shows that its there and it would work if I would use lower case in declaration

Or if use of $ like this, but it is not in documentation

book.{$MY_DOMAIN} {
    reverse_proxy bookstack:80
}
bug

Most helpful comment

@DoTheEvo I've fixed this in 829e36d and tested that it worked for me; that build should have CI artifacts in a few minutes. Care to try it out and confirm on your end?

All 4 comments

@DoTheEvo Thanks for the report! I'll take a look at this. It appears that the Caddyfile adapter is lowercasing it in the final JSON output: caddy adapt will reveal this.

The syntax {$MY_DOMAIN} is actually documented: https://caddyserver.com/docs/caddyfile/concepts#environment-variables

The difference between {$ and {env. is that {$ is evaluated before Caddyfile parsing begins, and {env. is evaluated at runtime. This matters if your config is adapted in a different environment from which it is being run.

The syntax {$MY_DOMAIN} is actually documented: https://caddyserver.com/docs/caddyfile/concepts#environment-variables

nice, I was reading
https://caddyserver.com/docs/conventions#placeholders

I'm glad you were at least reading it 馃槄 The Caddyfile is its own little wrapper program over Caddy, that doesn't have anything to do with the internals of Caddy, so it's hard to link all the documentation together...

@DoTheEvo I've fixed this in 829e36d and tested that it worked for me; that build should have CI artifacts in a few minutes. Care to try it out and confirm on your end?

Was this page helpful?
0 / 5 - 0 ratings