1. Caddy version (caddy version
):
v2.1.1 h1:X9k1+ehZPYYrSqBvf/ocUgdLSRIuiNiMo7CvyGUQKeA=
2. How I run Caddy:
Installed through the https://apt.fury.io/caddy/ repository on Ubuntu 20.04. Configuration in /etc/caddy/Caddyfile
a. System environment:
Ubuntu 20.04, systemd
b. Command:
systemctl start caddy
c. Service/unit/compose file:
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target
[Service]
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
d. My complete Caddyfile or JSON config:
(logging) {
log {
output file /var/log/caddy/{args.0}.log
}
}
:80/test/* {
redir * https://www.google.com/
import logging test
}
:80/test2/* {
redir * https://www.bing.com/
import logging test2
}
3. The problem I’m having:
I’m trying to create a config where requests to different paths end up in different log files. The Caddyfile above is the closest I got to having this, but I’m having trouble getting it to work.
4. Error messages and/or full log output:
There’s not really error messages, but the second log file for test2
is never created. If I use different port numbers (:80
and :81
for example) both log files are created.
5. What I already tried:
A million things. Handlers, routes, adding custom fields to the logs. My end goal is a way to add some sort of tag to a log entry based on what path the client visited. So for example:
/test → add tag “Path-01”
/test2 → add tag “Path-02”