V2: Unrecognized directive when import external Caddyfile

1. Caddy version (caddy version):

Output of caddy version:

v2.0.0-rc.2 h1:7NOaxYrsnQ5D3rcLGn2UnLZHLfBpgrfM/JNTLhjCJ1c=

2. How I run Caddy:

a. System environment:

18.04.1-Ubuntu

b. Command:

Just caddy start or caddy run in the folder where the main Caddyfile is.

c. My complete Caddyfile:

main Caddyfile:

http://

@mobile {
  header_regexp User-Agent Mobile|Android|BlackBerry
}

reverse_proxy @mobile localhost:8082
reverse_proxy localhost:8081 

import /path/to/another/Caddyfile

another Caddyfile:

:2018 {
  file_server browse
}

3. The problem I’m having:

Caddy won’t start, and with the following error.

4. Error messages and/or full log output:

adapting config using caddyfile: /path/to/another/Caddyfile:1: unrecognized directive: :2018

5. What I already tried:

I’ve tried to modify the first line from :2018 to something like localhost:2018, neither of them worked.

And the result of caddy validate was fine.

Hi all.

I’ve found out why the error happened.

This was because I didn’t wrap up the http:// part in curly braces.

Glad you figured it out!

FYI, Caddy v2.0.0 stable was just released on Monday, you’re using an old version.

Thanks for your kindness!

1 Like

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