1. Output of caddy version
:
v2.6.1 h1:EDqo59TyYWhXQnfde93Mmv4FJfYe00dO60zMiEt+pzo=
2. How I run Caddy:
Debian package, via default systemd unit.
a. System environment:
b. Command:
systemctl start caddy
d. My complete Caddy config:
int.server.company.bogus {
root * /srv/www
tls /etc/ssl/private/snakeoil-cert.pem /etc/ssl/private/snakeoil-key.pem
handle_path /sites* {
root * /srv/data/sites
@css path *.css
header @css Content-Type text/css
@svg path *.svg
header @svg Content-Type image/svg+xml
@js path *.js
header @js Content-Type text/javascript
@html path *.html *.htm
header @html Content-Type text/html
@has_gzip file {path}.gz
handle @has_gzip {
header Content-Encoding gzip
rewrite {http.matchers.file.relative}
}
file_server browse
}
file_server
}
3. The problem I’m having:
I have a big collection of quite compressible files, which aren’t changed that often. Therefore it would be nice to just save them compressed and have caddy serve them as either compressed or uncompressed (if the client really doesn’t support compressed respones). Currently, when running a caddy fileserver with the precompressed
option, caddy only delivers the compressed variants of a file if the uncompressed file also exists…
(Currently, I’m helping myself with a more complex configuration inspired by Why caddy 2 is not able to serve static brotli files? - #28 by Whitestrake - It is lacking a bit, since it won’t serve clients without gzip support)
6. Links to relevant resources:
Since I was migrating from nginx, which has this feature, here is a reference on how this works on nginx: