1. Caddy version:
v2.6.2
2. How I installed, and run Caddy:
use service file
a. System environment:
ubuntu 20 amd64
b. Command:
c. Service/unit/compose file:
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/caddy run --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile --force
[Install]
WantedBy=multi-user.target
d. My complete Caddy config:
{
auto_https disable_redirects
}
(base_configuration) {
root * .
file_server {
index index.html
}
handle_errors {
rewrite * /index.html
file_server
}
}
:80 {
import base_configuration
}
:443 {
tls /etc/caddy/cert/server.crt /etc/caddy/cert/server.key
import base_configuration
}
3. The problem I’m having:
I use it on my laptop. I work with no problem. But, when I use it on my VPS. It can not find my index.html. It return me HTTP 404.
4. Error messages and/or full log output:
Feb 03 12:45:27 shywind1.server.com caddy[65547]: {"level":"error","ts":1675424727.1523185,"logger":"http.log.error","msg":"error handling handler error","request":{"remote_ip":"122.116.52.140","remote_port":"51092","proto":"HTTP/1.1","method":"GET","host":"103.61.139.106","uri":"/index.html","headers":{"Accept-Language":["zh,zh-TW;q=0.9,zh-CN;q=0.8,en;q=0.7,en-US;q=0.6,ru;q=0.5"],"Cookie":[],"Connection":["keep-alive"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"],"Accept-Encoding":["gzip, deflate"],"Cache-Control":["max-age=0"]}},"duration":0.001510796,"error":"{id=y14qsx062} fileserver.(*FileServer).notFound (staticfiles.go:579): HTTP 404","first_error":{"msg":"{id=hpscjfjbm} fileserver.(*FileServer).notFound (staticfiles.go:579): HTTP 404","status":404,"err_id":"hpscjfjbm","err_trace":"fileserver.(*FileServer).notFound (staticfiles.go:579)"}}
5. What I already tried:
When I use command line to execute it. That works normally.
/usr/bin/caddy run --config /etc/caddy/Caddyfile