1. Caddy version (caddy version
):
v2.1.1
2. How I run Caddy:
a. System environment:
Ubuntu 20.04
b. Command:
systemctl start caddy
c. Service/unit/compose file:
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target
[Service]
User=caddy
Group=caddy
ReadWritePaths=/customPath/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:
{
email admin@example.com
}
subdomain.example.com {
root * /var/www/subdomain
file_server
log {
output file /var/log/subdomain.log
format single_field common_log
}
php_fastcgi unix//run/php/php7.4-fpm.sock
header {
Strict-Transport-Security "max-age=15552000;"
X-Frame-Options "SAMEORIGIN" always
X-Permitted-Cross-Domain-Policies "none" always
X-Robots-Tag "none" always
X-XSS-Protection "1; mode=block" always
X-Content-Type-Options "nosniff"
}
redir /.well-known/carddav /remote.php/dav 301
redir /.well-known/caldav /remote.php/dav 301
redir /.well-known/webfinger /public.php?service=webfinger
redir /.well-known/host-meta /public.php?service=host-meta
redir /.well-known/host-meta\.json /public.php?service=host-meta-json
# .htaccess / data / config / ... shouldn't be accessible from outside
@forbidden {
path /.htaccess
path /data/*
path /config/*
path /db_structure
path /.xml
path /README
path /3rdparty/*
path /lib/*
path /templates/*
path /occ
path /console.php
}
respond @forbidden 404
}
3. The problem I’m having:
The HomeDir for caddy is wrong
$ caddy environ
caddy.HomeDir=/home/twinkybot
caddy.AppDataDir=/home/twinkybot/.local/share/caddy
caddy.AppConfigDir=/home/twinkybot/.config/caddy
caddy.ConfigAutosavePath=/home/twinkybot/.config/caddy/autosave.json
I want it to be /caddy, which I managed with
ReadWritePaths=/customPath/caddy in my service file.
But I want this to be in the Caddyfile. What do I need to configure?
Thanks.