1. Caddy version (caddy version
):
v2.1.1
2. How I run Caddy:
/usr/bin/caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
a. System environment:
Docker, alpine 3.12, interactive session.
b. Command:
/usr/bin/caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
c. Service/unit/compose file:
N/A
d. My complete Caddyfile or JSON config:
sub.domain.com {
tls /etc/ssl/cert.pem /etc/ssl/key.pem
encode gzip
root * /www
@ipfilter {
not remote_ip 192.168.100.0/24
}
respond @ipfilter 403
@zxp {
path_regexp myregex ^/([zx]p?)/(.*)/(.+\.(?:gif|jpe?g|png|txt|html?|css|js))$
}
rewrite @zxp /mnt/{http.matchers.path_regexp.myregex.1}/{http.matchers.path_regexp.myregex.2}/img/{http.matchers.path_regexp.myregex.3}
file_server
log {
output stdout
format single_field common_log
}
header Strict-Transport-Security max-age=31536000;
}
3. The problem I’m having:
Idea is, that when user goes to https://sub.domain.com/z/blah/image.png, image is sourced from the /mnt/z/blah/img/image.png
directory on the server. The file is present, but every time I get 404 error.
As a troubleshooting step, I replaced rewrite
detective with the
respond @zxp "FOUND" 200
and when making queries to the expected urls, I get FOUND and code 200 in the browser. So perhaps I’m somewhere near, but not getting it…
Basically, I’m looking for something like Nginx’s alias detective.