1. Caddy version (caddy version
):
v2.1.1 (official docker image)
2. How I run Caddy:
I’m using Caddy as a simple static webserver. I really like the JSON logs, but I also want common logs so I can point fail2ban at them. I would like to configure my site to log twice, once for JSON and once for common.
a. System environment:
Raspberry Pi 4
Ubuntu 20.04.1 Server
Docker version 19.03.8
b. Command:
Whatever the official docker image does by default
c. Service/unit/compose file:
caddy:
image: caddy
container_name: caddy
hostname: caddy
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
- ./caddy/data:/data
- ./caddy/config:/config
- ./caddy/landing:/srv/landing
d. My complete Caddyfile or JSON config:
# logging
(logging) {
log {
format json
output file /data/log/caddy.log {
roll_size 50MiB
roll_keep 10
roll_keep_for 8760h
}
}
#log {
# format single_field common_log
# output file /data/log/access.log {
# roll_size 50MiB
# roll_keep 10
# roll_keep_for 8760h
# }
#}
}
# Root site
landing.dinn.ca, landing.stevedinn.com {
root * /srv/landing
file_server
import logging
}
3. The problem I’m having:
I can’t figure out the correct way to configure multiple log output for my site in Caddy. I’m sure it is possible, but despite poring over the documentation and this forum, I can’t seem to get it right.
4. Error messages and/or full log output:
I don’t really have anything to post here.
5. What I already tried:
So far, I’ve tried having multiple log
sections in my logging
snippet, but it only uses the last one, not both.
6. Links to relevant resources:
This post seems to have come the closest so far to an answer that I can digest, but I’m not there yet.
I’m a Caddy noob, but I’ve really tried my best to get this to work. I find that there are a distant lack of complete examples of configuration in the documentation. I see lots of snippets of configuration, but it’s hard to know where they all are supposed to go.
Edit: Missed pasting in my docker-compose snippet.