How to monitor included files

1. Output of caddy version:

v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=

2. How I run Caddy:

In docker see below.

a. System environment:

Running in Docker on Ubuntu 18.04

b. Command:

See the docker compose file below.

c. Service/unit/compose file:

version: 3.5
services:
  caddy:
    image: caddy
    container_name: caddy
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
      - 2019:2019
    volumes:
      - /opt/caddy/Caddyfile:/etc/caddy/Caddyfile
      - /opt/caddy/data:/data
      - /opt/caddy/config:/config
    networks:
      - internal
    command: [ "caddy", "run", "--watch", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile" ]

d. My complete Caddy config:

{
  log {
    output stdout
  }
}

(auth) {
   forward_auth authelia:9091 {
     uri /api/verify?rd=https://auth.example.com/
     copy_headers Remote-User Remote-Groups Remote-Name Remote-Email
   }
}

import /config/caddy/caddylocal.conf
import /config/caddy/caddymini.conf

3. The problem I’m having:

I have included the --watch flag in my docker compose file and I believe this works if the main Caddyfile is updated, however it doesn’t monitor the imported config files, is there a way to watch these too? I am using docker-gen to generate these files, one is based on the local docker instance and one is based on a remote one. The config files work fine and if I do a docker exec caddy caddy reload --config /etc/caddy/Caddyfile then everything loads up ok.

If there isn’t a way to monitor the imported files is there a way to issue a curl command to reload the config? I’ve been looking at the api and I can’t see a way to tell it to reload the config from the filesystem.

I have also looked at initiating a docker exec from docker-gen but because it needs to create the command then start it, this is getting beyond a one shot approach and might need some command line pipeing that is a bit beyond me.

4. Error messages and/or full log output:

No errors in log file.

5. What I already tried:

See section 3

6. Links to relevant resources:

You might be interested in using CDP instead:

That said, there’s an open feature request for watching imported files. It hasn’t been worked on yet, because it’s typically only useful during debugging and not once you reach production, so it’s not really a priority for us to implement.

1 Like

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