HomePage 404 problem

1. Caddy version:


2. How I installed, and run Caddy:

use service file

a. System environment:

ubuntu 20 amd64

b. Command:

c. Service/unit/compose file:

After=network.target network-online.target

ExecStart=/usr/bin/caddy run --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile --force


d. My complete Caddy config:

  auto_https disable_redirects

(base_configuration) {
    root * .
    file_server {
        index index.html
    handle_errors {
            rewrite * /index.html

: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":"","remote_port":"51092","proto":"HTTP/1.1","method":"GET","host":"","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/ 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

6. Links to relevant resources:

This means “the current working directory of Caddy”.

When you’re running Caddy as a service, this path will probably be the HOME of the user under which Caddy is running.

You should probably use an absolute path instead, to make sure there’s no ambiguity.

If that still doesn’t work, enable the debug global option and look again at your logs. It might reveal more detail about the problem.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.