danix
(Danilo Macrì)
1
The problem I’m having:
I’m testing caddy in a local machine that I reach at
http://webserver.network.local
and it serves a static website generated with hugo.
I’m trying to serve a file listing from a subdirectory of the domain.
I want to serve some static files from
http://webserver.network.local/packages
with a directory listing, but I keep getting 404 when trying to access it. The hugo site works normally.
Caddy version:
caddy 2.6.2
How I installed and ran Caddy:
caddy was installed as a system package and runs from systemctl
System environment:
the server runs Debian 13.4 with systemd
Command:
systemctl start caddy
My complete Caddy config:
:80 {
handle /packages/ {
root * /var/www/html/packages
file_server {
browse
}
}
root * /var/www/html
file_server
}
I’ve always used apache, but wanted to try caddy. I feel like I’m missing something, because I’m sure this is trivial to obtain.
Thanks in advance for your help
danix
(Danilo Macrì)
3
thanks a lot, I’ve updated caddy with its own repository, which is more up to date than the standard debian package is.
I’ve also learned about debug mode, which I didn’t know existed 
My caddyfile is now:
:80 {
handle /packages/* {
file_server {
browse
}
}
root * /var/www/html
file_server
}
and it works if I point my browser at
http://webserver.network.local/packages/
but it won’t add the final slash, so if I go to
http://webserver.network.local/packages
In this latter case, it will still throw a 404.
But this is a minor issue for me.
Thanks a lot for your help
1 Like
timelordx
(timelordx)
4
Add this line above you handle line:
redir /packages /packages/
2 Likes
danix
(Danilo Macrì)
5
it works like a charm!!!
Thanks a lot for your help
1 Like