Caddyfile warning

1. Caddy version (caddy version):


2. How I run Caddy:


a. System environment:


b. Command:

docker-compose up -d
docker exec -w /etc/caddy caddy caddy validate

c. Service/unit/compose file:

version: "3.7"

    image: caddy
    container_name: caddy
    hostname: caddy
    restart: unless-stopped
      - "80:80"
      - "443:443"
      - MY_DOMAIN
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - ./data:/data
      - ./config:/config

      name: $DOCKER_MY_NETWORK

d. My complete Caddyfile or JSON config:

vaultwarden.{$MY_DOMAIN} {
    reverse_proxy vaultwarden:80

portainer.{$MY_DOMAIN} {
    reverse_proxy portainer:9000

3. The problem I’m having:

I dont have a problem and everything works, just curious, because it throws warning when doing graceful reload / or validating Caddyfile. Just for education purposes.

4. Error messages and/or full log output:

│ {“level”:“info”,“ts”:1632171529.1133611,“msg”:“using provided configuration”,“config_file”:"/etc/caddy/Caddyfile",“config_adapter”:“caddyfile”} │
│ {“level”:“warn”,“ts”:1632171529.118295,“msg”:“input is not formatted with ‘caddy fmt’”,“adapter”:“caddyfile”,“file”:"/etc/caddy/Caddyfile",“line”:2} │
│ {“level”:“info”,“ts”:1632171529.1271234,“logger”:“admin”,“msg”:“admin endpoint started”,“address”:“tcp/localhost:2019”,“enforce_origin”:false,“origins”:[“localhost:2019”,"[::1]:2019",“”]} │
│ {“level”:“info”,“ts”:1632171529.1305757,“logger”:“http”,“msg”:“server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS”,“server_name”:“srv0”,“https_port”:443} │
│ {“level”:“info”,“ts”:1632171529.1307333,“logger”:“http”,“msg”:“enabling automatic HTTP->HTTPS redirects”,“server_name”:“srv0”} │
│ {“level”:“info”,“ts”:1632171529.131466,“logger”:“tls.cache.maintenance”,“msg”:“started background certificate maintenance”,“cache”:“0x4000112070”} │
│ {“level”:“info”,“ts”:1632171529.132646,“logger”:“tls”,“msg”:“cleaning storage unit”,“description”:“FileStorage:/data/caddy”} │
│ {“level”:“info”,“ts”:1632171529.1332653,“logger”:“http”,“msg”:“enabling automatic TLS certificate management”,“domains”:[“vaultwarden.REDACTED”,“portainer.REDACTED”]} │
│ {“level”:“info”,“ts”:1632171529.139218,“logger”:“tls”,“msg”:“finished cleaning storage units”} │
│ {“level”:“info”,“ts”:1632171529.1403375,“msg”:“autosaved config (load with --resume flag)”,“file”:"/config/caddy/autosave.json"} │
│ {“level”:“info”,“ts”:1632171529.1405272,“msg”:“serving initial configuration”}

5. What I already tried:

I dont know what should I do to suppress this warning.

6. Links to relevant resources:

Please use code fences when posting logs. Put ``` on their own lines, before and after the logs.

This warning is prompting you to run caddy fmt on your config, to clean up the formatting.

Since you have Caddy in docker, you could run it like this to clean it up:

$ docker run --rm \
  -v "$(pwd)/Caddyfile:/srv/Caddyfile" \
  caddy \
  caddy fmt

Basically, this will run a docker container, using --rm to mark it as immediately removed after running, then mount your Caddyfile in /srv, which is the default WORKDIR for the caddy docker image, then specifies caddy as the image name to run, and finally caddy fmt as the command to run inside it.

You’ll see this outputs your Caddyfile, formatted, to stdout. You can redirect the output to overwrite your Caddyfile by adding > ./Caddyfile at the end of the command.

In this case, your Caddyfile is using spaces, instead of tabs. We standardized the format for the Caddyfile to use tabs, for the same reasons that gofmt uses tabs.

1 Like

Thank you very much for your comprehensive answer, the warning persists, but at line 6 now. There are no spaces in the config after cleanup and it looks like exactly as stdout. The other command with redirect to output file - well, I am not really sure if somethig happens.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.