1. My Caddy version (caddy version
):
(devel) Caddyv2 latest commit: 115b877
2. How I run Caddy:
/etc/caddy/caddy run --config /etc/caddy/Caddyfile --adapter caddyfile --resume --environ
a. System environment:
Debian 10 x64 via Systemd
b. Command:
Service v2caddy start
c. Service/unit/compose file:
[Unit]
Description=Caddy v2 Web Server
Documentation=https://caddyserver.com/docs/
After=network.target
[Service]
User=root
Group=root
ExecStart=/etc/caddy/caddy run --config /etc/caddy/Caddyfile --adapter caddyfile --resume --environ
ExecReload=/etc/caddy/caddy reload --config /etc/caddy/Caddyfile --adapter caddyfile
TimeoutStopSec=5s
LimitNOFILE=8000000
LimitNPROC=8192
[Install]
WantedBy=multi-user.target
d. My complete Caddyfile or JSON config:
167.86.123.102:80, [2a02:c207:3004:1207:be:a:bad:babe]:80 {
redir https://hnrk.io{uri} 301
}
hnrk.io, www.hnrk.io {
root * /etc/caddy/html
tls /etc/caddy/hnrk.io.crt /etc/caddy/hnrk.io.key
encode brotli zstd gzip
php_fastcgi unix//run/php/php7.4-fpm.sock
try_files {path} {path}/index.php /index.php?{query}
header * {
Strict-Transport-Security "max-age=31536000; includeSubdomains; preload"
X-XSS-Protection "1; mode=block"
X-Content-Type-Options "nosniff"
X-Frame-Options "SAMEORIGIN"
}
file_server /md* browse
file_server
}
mail.hnrk.io {
root * /etc/caddy/html/rl
tls /etc/caddy/hnrk.io.crt /etc/caddy/hnrk.io.key
encode brotli zstd gzip
php_fastcgi unix//run/php/php7.4-fpm.sock
try_files {path} {path}/index.php /index.php?{query}
header * {
Strict-Transport-Security "max-age=31536000; includeSubdomains; preload"
X-XSS-Protection "1; mode=block"
X-Content-Type-Options "nosniff"
X-Frame-Options "SAMEORIGIN"
}
file_server /data {
hide *
}
file_server
}
3. The problem I’m having:
Relevant config block is the “mail.hnrk.io” one!
I use Rainloop Webmail and it keeps reporting that subfolder “/data” is accessible, so I’d like to hide this entire folder from external access.
In that “/data”-folder, there is an index.php and index.html, whose content is “Forbidden”. Using double file_server directives like above config still lets me see index.html and .php in data-folder, browser says “Forbidden”.
I’ve also tried these, but still rainloop reports me the warning above:
file_server * {
hide /data
}
file_server
____________________________________________
file_server * {
hide /data/*
}
file_server
____________________________________________
file_server /data* {
hide *
}
file_server
____________________________________________
file_server * {
hide /data/*
}
6. Links to relevant resources:
Unfortunately, Rainloop documentation does not have an example config for Caddy (v2), maybe if I find a way to hide the data folder properly, I’ll propose one for them .
Thanks!