Update topic:
=========================================================================
config file content:
The Caddyfile is an easy way to configure your Caddy web server.
Unless the file starts with a global options block, the first
uncommented line is always the address of your site.
To use your own domain name (with automatic HTTPS), first make
sure your domain’s A/AAAA DNS records are properly pointed to
this machine’s public IP, then replace “:80” below with your
domain name.
{
debug
}
sub.domainname.com {
tls admin@sub.domainname.com
# Set this path to your site's directory.
# root * /usr/share/caddy
root * /var/www/html
# Enable the static file server.
file_server
log {
output file /var/log/caddy/access.log
}
# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080
# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000
}
Refer to the Caddy docs for more information:
=========================================================================
“systemctl status caddy -l” results:
Jan 09 23:41:06 sub.domainname.com caddy[1148]: {“level”:“debug”,“ts”:1673295066.0813782,“logger”:“http.log.error.log0”,“msg”:“stat /var/www/html/index.html: permission denied”,“request”:{“remote_ip”:“Remote_IP_ADDRESS”,“remote_port”:“3416”,“proto”:“HTTP/2.0”,“method”:“GET”,“host”:“sub.domainname.com”,“uri”:“/index.html”,“headers”:{“Sec-Fetch-Site”:[“none”],“Accept-Language”:[“en-US,en;q=0.9,fa;q=0.8”],“Accept”:[“text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9”],“Upgrade-Insecure-Requests”:[“1”],“Sec-Fetch-Dest”:[“document”],“Accept-Encoding”:[“gzip, deflate, br”],“Cookie”:[],“Pragma”:[“no-cache”],“Sec-Ch-Ua”:[“"Not?A_Brand";v="8", "Chromium";v="108", "Microsoft Edge";v="108"”],“User-Agent”:[“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.76”],“Cache-Control”:[“no-cache”],“Sec-Ch-Ua-Platform”:[“"Windows"”],“Sec-Fetch-Mode”:[“navigate”],“Sec-Fetch-User”:[“?1”],“Sec-Ch-Ua-Mobile”:[“?0”]},“tls”:{“resumed”:false,“version”:772,“cipher_suite”:4865,“proto”:“h2”,“server_name”:“sub.domainname.com”}},“duration”:0.006297215,“status”:403,“err_id”:“8c5z454pv”,“err_trace”:“fileserver.(*FileServer).ServeHTTP (staticfiles.go:253)”}
Jan 09 23:41:06 sub.domainname.com caddy[1148]: 2023-01-09 23:41:06.081456554 +0330 +0330 m=+71.616143385 write error: can’t rename log file: rename /var/log/caddy/access.log /var/log/caddy/access-2023-01-09T20-11-06.082.log: permission denied
Jan 09 23:41:09 sub.domainname.com caddy[1148]: {“level”:“debug”,“ts”:1673295069.9932365,“logger”:“http.handlers.file_server”,“msg”:“sanitized path join”,“site_root”:“/var/www/html”,“request_path”:“/”,“result”:“/var/www/html”}
Jan 09 23:41:09 sub.domainname.com caddy[1148]: {“level”:“debug”,“ts”:1673295069.9934742,“logger”:“http.handlers.file_server”,“msg”:“no index file in directory”,“path”:“/var/www/html”,“index_filenames”:[“index.html”,“index.txt”]}
Jan 09 23:41:09 sub.domainname.com caddy[1148]: {“level”:“debug”,“ts”:1673295069.9935436,“logger”:“http.log.error.log0”,“msg”:“{id=dev40jzk8} fileserver.(FileServer).notFound (staticfiles.go:579): HTTP 404",“request”:{“remote_ip”:“Remote_IP_ADDRESS”,“remote_port”:“3416”,“proto”:“HTTP/2.0”,“method”:“GET”,“host”:“sub.domainname.com”,“uri”:“/”,“headers”:{“Cookie”:[],“Sec-Ch-Ua-Mobile”:[“?0”],“Sec-Fetch-Site”:[“none”],“Sec-Fetch-Mode”:[“navigate”],“Sec-Fetch-User”:[“?1”],“Sec-Fetch-Dest”:[“document”],“Accept-Encoding”:[“gzip, deflate, br”],“Accept-Language”:[“en-US,en;q=0.9,fa;q=0.8”],“Sec-Ch-Ua”:[“"Not?A_Brand";v="8", "Chromium";v="108", "Microsoft Edge";v="108"”],“Sec-Ch-Ua-Platform”:[“"Windows"”],“Upgrade-Insecure-Requests”:[“1”],“User-Agent”:[“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.76”],“Accept”:["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/*;q=0.8,application/signed-exchange;v=b3;q=0.9”]},“tls”:{“resumed”:false,“version”:772,“cipher_suite”:4865,“proto”:“h2”,“server_name”:“sub.domainname.com”}},“duration”:0.00030641,“status”:404,“err_id”:“dev40jzk8”,“err_trace”:“fileserver.(*FileServer).notFound (staticfiles.go:579)”}
Jan 09 23:41:09 sub.domainname.com caddy[1148]: 2023-01-09 23:41:09.993564957 +0330 +0330 m=+75.528251759 write error: can’t rename log file: rename /var/log/caddy/access.log /var/log/caddy/access-2023-01-09T20-11-09.993.log: permission denied
Jan 09 23:41:12 sub.domainname.com caddy[1148]: {“level”:“debug”,“ts”:1673295072.6095545,“logger”:“http.handlers.file_server”,“msg”:“sanitized path join”,“site_root”:“/var/www/html”,“request_path”:“/”,“result”:“/var/www/html”}
Jan 09 23:41:12 sub.domainname.com caddy[1148]: {“level”:“debug”,“ts”:1673295072.6096947,“logger”:“http.handlers.file_server”,“msg”:“no index file in directory”,“path”:“/var/www/html”,“index_filenames”:[“index.html”,“index.txt”]}
Jan 09 23:41:12 sub.domainname.com caddy[1148]: {“level”:“debug”,“ts”:1673295072.6097376,“logger”:“http.log.error.log0”,“msg”:“{id=rexh904wg} fileserver.(FileServer).notFound (staticfiles.go:579): HTTP 404",“request”:{“remote_ip”:“Remote_IP_ADDRESS”,“remote_port”:“3416”,“proto”:“HTTP/2.0”,“method”:“GET”,“host”:“sub.domainname.com”,“uri”:“/”,“headers”:{“Accept”:["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/*;q=0.8,application/signed-exchange;v=b3;q=0.9”],“Sec-Fetch-Mode”:[“navigate”],“Pragma”:[“no-cache”],“Sec-Ch-Ua”:[“"Not?A_Brand";v="8", "Chromium";v="108", "Microsoft Edge";v="108"”],“Cookie”:[],“Cache-Control”:[“no-cache”],“Sec-Ch-Ua-Mobile”:[“?0”],“Sec-Fetch-Site”:[“none”],“Sec-Fetch-Dest”:[“document”],“Accept-Encoding”:[“gzip, deflate, br”],“Accept-Language”:[“en-US,en;q=0.9,fa;q=0.8”],“Sec-Ch-Ua-Platform”:[“"Windows"”],“Upgrade-Insecure-Requests”:[“1”],“User-Agent”:[“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.76”],“Sec-Fetch-User”:[“?1”]},“tls”:{“resumed”:false,“version”:772,“cipher_suite”:4865,“proto”:“h2”,“server_name”:“sub.domainname.com”}},“duration”:0.000225454,“status”:404,“err_id”:“rexh904wg”,“err_trace”:“fileserver.(*FileServer).notFound (staticfiles.go:579)”}
Jan 09 23:41:12 sub.domainname.com caddy[1148]: 2023-01-09 23:41:12.609757303 +0330 +0330 m=+78.144444113 write error: can’t rename log file: rename /var/log/caddy/access.log /var/log/caddy/access-2023-01-09T20-11-12.609.log: permission denied