Unrecognized Directive

1. Caddy version (caddy version):

v2.1.1

2. How I run Caddy:

DDNS for caddy.mydomain.com resolves to my ip. This fqdn is in my Caddyfile. I am able to see the Caddy splashpage, and it runs on HTTPS like it should. plex.mydomain.com is a CNAME to caddy.mydomain.com

a. System environment:

ubuntu server 18.04 via apt repo

b. Command:

systemctl start caddy
systemctl stop caddy
systemctl reload caddy

d. My complete Caddyfile or JSON config:

# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace the line below with your
# domain name.
caddy.mydomain.com
# Set this path to your site's directory.
root * /usr/share/caddy
# Enable the static file server.
file_server
# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080

# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000

# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile
#
#
plex.mydomain.com {
     reverse_proxy http://10.0.80.247:32400
}

3. The problem I’m having:

I receive an “unrecognized directive” error when attempted to do a reverse proxy. I’ve tried both reverse_proxy and proxy / methods - both give the same error. Even putting the subdomain entry in the caddy file with nothing in it gives me the error.

4. Error messages and/or full log output:

adapt: Caddyfile:25: unrecognized directive: plex.mydomain.com

5. What I already tried:

Tried several ways to format the reverse proxy block.

Figured it out with more searching… the root * /usr/share/caddy and file_server have to be in curly braces with the main site, THEN it correctly parses the subdomain.

1 Like

Glad you figured it out!

FYI it’s explained here in the docs:

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