Simple file_server gives HTTP ERROR 404 error

1. Caddy version (caddy version):

Caddy v2.2.1

2. How I run Caddy:

sudo systemctl start caddy

a. System environment:

ubuntu 18.04

d. My complete Caddyfile or JSON config:

www.domain.tdl {
    root * /path/to/www
    file_server
}

3. The problem I’m having:

Hi, i want to serve my index.html but domain giving HTTP ERROR 404 error
thank you

Does Caddy running as a service have read access to that file? Does it work if you run Caddy from the command line?

Paul

1 Like

-Does Caddy running as a service have read access to that file?
-Yes

-Does it work if you run Caddy from the command line?
-Yes, Caddy’s status active

When i put json its work well but if Caddyfile i got error

-Working json file bellow

{
  "apps": {
    "http": {
      "servers": {
        "srv0": {
          "listen": [
            ":443"
          ],
          "routes": [
            {
              "@id": "3-domain",
              "handle": [
                {
                  "handler": "file_server",
                  "root": "/path/to/www"
                }
              ],
              "match": [
                {
                  "host": [
                    "www.domain.tdl"
                  ]
                }
              ],
              "terminal": true
            }
          ]
        }
      }
    }
  }
}

Hi pwhodges,
I doubted after what you wrote. i add caddy user to www-data group which is directory of domains.

sudo adduser caddy www-data

its working now. thank you

1 Like