1. My Caddy version (caddy version
):
(devel) V2 RC2
2. How I run Caddy:
systemctl start caddy
# change Caddyfile...
systemctl reload caddy
a. System environment:
uname -a
Linux 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1 (2020-01-26) x86_64 GNU/Linux
b. Command:
systemctl reload caddy
c. Service/unit/compose file:
# caddy.service
#
# For using Caddy with a config file.
#
# Make sure the ExecStart and ExecReload commands are correct
# for your installation.
#
# WARNING: This service does not use the --resume flag, so if you
# use the API to make changes, they will be overwritten by the
# Caddyfile next time the service is restarted. If you intend to
# use Caddy's API to configure it, add the --resume flag to the
# `caddy run` command or use the caddy-api.service file instead.
[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:
example.com {
log {
output file /var/log/caddy_access.log
}
respond / "This works"
file_server /test {
root /srv/www/test
}
}
3. The problem I’m having:
I’m trying to have this site serve a simple text response on the /
path and then have a file_server
directive serve a simple index file from the /test
path.
The respond
directive is working fine: Status 200, the simple body text is returned.
The /test
path gives me a 404.
4. Error messages and/or full log output:
No errors.
5. What I already tried:
I’ve tried the following:
Test that the file_server works on the root path:
This works fine, the index.html is served from the /srv/www/test
directory when getting the /
path.
example.com {
log {
output file /var/log/caddy_access.log
}
root * /srv/www/test
file_server
}
Test if the file_server directive works with a global root directive and a path matcher
This doesn’t work. I get a 404 on /test
and a 200 on /
with the respond
text.
example.com {
log {
output file /var/log/caddy_access.log
}
respond / "This works"
root * /srv/www/test
file_server /test
}
6. Links to relevant resources:
N/A
Thanks in advance for your help!