1. Output of caddy version
:
v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=
2. How I run Caddy:
sudo service caddy start
a. System environment:
centos 8
Linux work 4.18.0-448.el8.x86_64 #1 SMP Wed Jan 18 15:02:46 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
b. Command:
sudo service caddy start
c. Service/unit/compose file:
I installed caddy by following these steps, so all things are default.
d. My complete Caddy config:
http://foo.com {
root * /home/opc/foo
file_server
}
3. The problem I’m having:
I got an error
Access to foo.com was denied
You don't have authorization to view this page.
HTTP ERROR 403
4. Error messages and/or full log output:
Run sudo journalctl -u caddy --no-pager | less +G
and got
y/Caddyfile","config_adapter":""}
Mar 11 13:29:36 work caddy[1984]: {"level":"warn","ts":1678541376.1268306,"msg":"Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":2}
Mar 11 13:29:36 work caddy[1984]: {"level":"info","ts":1678541376.127591,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//127.0.0.1:2019","//localhost:2019","//[::1]:2019"]}
Mar 11 13:29:36 work caddy[1984]: {"level":"warn","ts":1678541376.1282082,"logger":"http","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv0","http_port":80}
Mar 11 13:29:36 work caddy[1984]: {"level":"info","ts":1678541376.1284068,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
Mar 11 13:29:36 work caddy[1984]: {"level":"info","ts":1678541376.1285868,"msg":"autosaved config (load with --resume flag)","file":"/var/lib/caddy/.config/caddy/autosave.json"}
Mar 11 13:29:36 work caddy[1984]: {"level":"info","ts":1678541376.1286252,"msg":"serving initial configuration"}
Mar 11 13:29:36 work caddy[1984]: {"level":"info","ts":1678541376.128677,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc0001fc1c0"}
Mar 11 13:29:36 work caddy[1984]: {"level":"info","ts":1678541376.128696,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/var/lib/caddy/.local/share/caddy"}
Mar 11 13:29:36 work caddy[1984]: {"level":"info","ts":1678541376.1287093,"logger":"tls","msg":"finished cleaning storage units"}
Mar 11 13:29:36 work systemd[1]: Started Caddy.
Mar 11 13:32:19 work systemd[1]: Stopping Caddy...
Mar 11 13:32:19 work caddy[1984]: {"level":"info","ts":1678541539.0217068,"msg":"shutting down apps, then terminating","signal":"SIGTERM"}
Mar 11 13:32:19 work caddy[1984]: {"level":"warn","ts":1678541539.0217786,"msg":"exiting; byeee!! 👋","signal":"SIGTERM"}
Mar 11 13:32:19 work caddy[1984]: {"level":"info","ts":1678541539.023097,"logger":"tls.cache.maintenance","msg":"stopped background certificate maintenance","cache":"0xc0001fc1c0"}
Mar 11 13:32:19 work caddy[1984]: {"level":"info","ts":1678541539.0243573,"logger":"admin","msg":"stopped previous server","address":"localhost:2019"}
Mar 11 13:32:19 work caddy[1984]: {"level":"info","ts":1678541539.0243764,"msg":"shutdown complete","signal":"SIGTERM","exit_code":0}
Mar 11 13:32:19 work systemd[1]: caddy.service: Succeeded.
Mar 11 13:32:19 work systemd[1]: Stopped Caddy.
Mar 11 13:32:19 work systemd[1]: Starting Caddy...
Mar 11 13:32:19 work caddy[2025]: caddy.HomeDir=/var/lib/caddy
Mar 11 13:32:19 work caddy[2025]: caddy.AppDataDir=/var/lib/caddy/.local/share/caddy
Mar 11 13:32:19 work caddy[2025]: caddy.AppConfigDir=/var/lib/caddy/.config/caddy
Mar 11 13:32:19 work caddy[2025]: caddy.ConfigAutosavePath=/var/lib/caddy/.config/caddy/autosave.json
Mar 11 13:32:19 work caddy[2025]: caddy.Version=v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=
Mar 11 13:32:19 work caddy[2025]: runtime.GOOS=linux
Mar 11 13:32:19 work caddy[2025]: runtime.GOARCH=amd64
Mar 11 13:32:19 work caddy[2025]: runtime.Compiler=gc
Mar 11 13:32:19 work caddy[2025]: runtime.NumCPU=2
Mar 11 13:32:19 work caddy[2025]: runtime.GOMAXPROCS=2
Mar 11 13:32:19 work caddy[2025]: runtime.Version=go1.18.9
Mar 11 13:32:19 work caddy[2025]: os.Getwd=/
Mar 11 13:32:19 work caddy[2025]: LANG=en_US.UTF-8
Mar 11 13:32:19 work caddy[2025]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Mar 11 13:32:19 work caddy[2025]: NOTIFY_SOCKET=/run/systemd/notify
Mar 11 13:32:19 work caddy[2025]: HOME=/var/lib/caddy
Mar 11 13:32:19 work caddy[2025]: LOGNAME=caddy
Mar 11 13:32:19 work caddy[2025]: USER=caddy
Mar 11 13:32:19 work caddy[2025]: INVOCATION_ID=40b3994644b447369f55fdb6f406ff17
Mar 11 13:32:19 work caddy[2025]: JOURNAL_STREAM=9:34542
Mar 11 13:32:19 work caddy[2025]: {"level":"info","ts":1678541539.207737,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Mar 11 13:32:19 work caddy[2025]: {"level":"warn","ts":1678541539.2085576,"msg":"Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":2}
Mar 11 13:32:19 work caddy[2025]: {"level":"info","ts":1678541539.2092397,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//127.0.0.1:2019","//localhost:2019","//[::1]:2019"]}
Mar 11 13:32:19 work caddy[2025]: {"level":"warn","ts":1678541539.2096462,"logger":"http","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv0","http_port":80}
Mar 11 13:32:19 work caddy[2025]: {"level":"info","ts":1678541539.2098348,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
Mar 11 13:32:19 work caddy[2025]: {"level":"info","ts":1678541539.2110505,"msg":"autosaved config (load with --resume flag)","file":"/var/lib/caddy/.config/caddy/autosave.json"}
Mar 11 13:32:19 work caddy[2025]: {"level":"info","ts":1678541539.2111,"msg":"serving initial configuration"}
Mar 11 13:32:19 work caddy[2025]: {"level":"info","ts":1678541539.211154,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc00022e620"}
Mar 11 13:32:19 work caddy[2025]: {"level":"info","ts":1678541539.211177,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/var/lib/caddy/.local/share/caddy"}
Mar 11 13:32:19 work caddy[2025]: {"level":"info","ts":1678541539.2111893,"logger":"tls","msg":"finished cleaning storage units"}
Mar 11 13:32:19 work systemd[1]: Started Caddy.
Seem no error here.
5. What I already tried:
-
I disabled SELinux
-
groups caddy
→caddy : caddy wheel
-
ls -la /home/opc/foo
total 4 drwxrwxrwx. 2 caddy caddy 24 Mar 11 11:53 . drwx------. 4 opc opc 125 Mar 11 13:25 .. -rwxrwxrwx. 1 caddy caddy 9 Mar 11 11:53 index.html
-
sudo usermod -aG wheel caddy
, see from How to solve status 403 in Caddy version 2 - Help - Caddy Community
6. Links to relevant resources:
How to solve status 403 in Caddy version 2 - Help - Caddy Community
Thank you.