Using docker Caddy is not generating log per site

1. Caddy version (caddy version):

CADDY_VERSION v2.2.1

2. How I run Caddy:

running in docker
caddy run --config /etc/caddy/Caddyfile --adapter caddyfile

a. System environment:

linux x86_64 Ubuntu 20.04.1 LTS
Docker 5.20
avec portainer agent

b. Command:

caddy run --config /etc/caddy/Caddyfile --adapter caddyfile

c. Service/unit/compose file:

Standard portainer config import

volume
caddy_config	/config
caddy_data	/data
/etc/caddy/Caddyfile	/etc/caddy/Caddyfile

env
TZ	Europe/Paris

d. My complete Caddyfile or JSON config:

#Caddyfile

{
    #debug
    acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
    #auto_https disable_redirects
    #auto_https off
    #http_port 80
    #https_port 443
}

www.theg.vg {
    reverse_proxy 192.168.10.200

    log {
        output file /var/log/caddy/www_access.log {
            roll_size 100mb
            roll_keep 5
            roll_keep_for 720h
        }
    }
}

b.theg.vg {
# Description : komga-bd
    reverse_proxy 192.168.10.242:8080

    log {
        output file /var/log/caddy/komga-bd_access.log {
            roll_size 100mb
            roll_keep 5
            roll_keep_for 720h
        }
    }
}

j.theg.vg {
# Description : komga-jdr
    reverse_proxy 192.168.10.242:8100

    log {
        output file /var/log/caddy/komga-jdr_access.log {
            roll_size 100mb
            roll_keep 5
            roll_keep_for 720h
        }
    }
}

p.theg.vg {
# Description : komga-presse
    reverse_proxy 192.168.10.242:8090

    log {
        output file /var/log/caddy/komga-presse_access.log {
            roll_size 100mb
            roll_keep 5
            roll_keep_for 720h
        }
    }
}

3. The problem I’m having:

no log are generated in the folder /var/log/caddy/
no error message

4. Error messages and/or full log output:

{"level":"info","ts":1608059831.6418629,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"},
{"level":"info","ts":1608059831.6499827,"logger":"admin","msg":"admin endpoint started","address":"tcp/localhost:2019","enforce_origin":false,"origins":["localhost:2019","[::1]:2019","127.0.0.1:2019"]},
{"level":"info","ts":1608059831.6541324,"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":1608059831.6542213,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"},
{"level":"info","ts":1608059831.654762,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["b.theg.vg","j.theg.vg","p.theg.vg","www.theg.vg"]},
{"level":"info","ts":1608059831.6541402,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000320850"},
{"level":"info","ts":1608059831.6630588,"logger":"tls","msg":"cleaned up storage units"},
{"level":"info","ts":1608059831.6635895,"msg":"autosaved config","file":"/config/caddy/autosave.json"},
{"level":"info","ts":1608059831.6636217,"msg":"serving initial configuration"},

5. What I already tried:

set everyon RW on caddy log folder

user@kleber:/etc/caddy$ ls -la /var/log/ | grep caddy
drwxrwxrwx 2 root root 4096 Dec 15 19:08 caddy

it is the same Caddyfile used in another machine for test purpose where caddy is running in standard apt install, and logs are generated

6. Links to relevant resources:

I’m confused. If you’re running in Docker, then Caddy should be running as root inside the container, so it should have no trouble writing basically anywhere inside the container.

Are you looking for the logs inside the container or on the host? There seems to be a disconnect there.

You said your volumes are these:

caddy_config	/config
caddy_data	/data
/etc/caddy/Caddyfile	/etc/caddy/Caddyfile

None of those involve /var/log/caddy, so the logs would never appear on the host.

1 Like

@francislavoie, and… you are perfectly right. i’m myself confuse and did not set the path in the docker config.

so focused in the caddyfile config, i forgot that :sweat_smile: :tired_face:

Many thanks
and sorry for the noise
:slight_smile:

1 Like

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