Issue with 1st Caddyfile

1. Caddy version (caddy version):

Caddy 2.4.6 running on Debian 11.1

2. How I run Caddy:

a. System environment:

Debian 11.1 / systemd

b. Command:

caddy run

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config:

southafricasos.org, www.southafricasos.org {
    root /var/www/SouthAfricaSOS.org
    php_fastcgi unix//run/php/php7.4-fpm.sock
# php_fastcgi localhost:9000
    file_server
    encode gzip

    @disallowed {
        path /xmlrpc.php
        path *.sql
        path /wp-content/uploads/*.php
    }

    rewrite @disallowed '/index.php'
}

3. The problem I’m having:

Am trying to replace nginx with Caddy using just a Caddyfile, I’ve cribbed and modified.

Getting curious error saying there’s something wrong with line beginning with root.

4. Error messages and/or full log output:

root@localhost:/etc/caddy# caddy run
2021/11/12 22:40:25.580 INFO using adjacent Caddyfile
run: adapting config using caddyfile: parsing caddyfile tokens for ‘root’: Caddyfile:2 - Error during parsing: Wrong argument count or unexpected line ending after ‘root’
root@localhost:/etc/caddy#

5. What I already tried:

Have started, stopped caddy.
re-edited Caddyfile in case there were hidden line-end characters.

6. Links to relevant resources:

Please see the documentation for the root directive

You need to use a * as the second argument, otherwise the Caddyfile parser will read your root path as a path matcher.

FYI, single quoted strings are not valid in Caddy. Either use double quotes, backticks, or just omit the quote altogether.

1 Like

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