Help with subdomain config in Caddyfile

1. The problem I’m having:

Unable to get Caddy to restart with a subdomain.

2. Error messages and/or full log output:

{"level":"info","ts":1696899151.1037645,"msg":"using provided configuration","config_file":"/usr/local/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
Error: adapting config using caddyfile: /usr/local/etc/caddy/Caddyfile:32: unrecognized directive: owncloud.voncarmo.com
Error: caddy process exited with error: exit status 1

3. Caddy version: caddy-2.7.4_1

4. How I installed and ran Caddy:

Installed on FreeBSD 13.2-RELEASE-p2 via packages.

a. System environment: as above

b. Command:

service caddy restart

c. Service/unit/compose file:

n/a

d. My complete Caddy config:

# The Caddyfile is an easy way to configure your Caddy web server.
#
# 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.

# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
voncarmo.com {
                # Set this path to your site's directory:
                root * /usr/local/www/voncarmo.com

                # Enable the static file server:
                file_server

                # Set up a reverse proxy:
                # reverse_proxy localhost:8080

                # Serve a PHP site through php-fpm:
                # php_fastcgi localhost:9000
                php_fastcgi unix//var/run/php81.sock
                # Enable logging:
                log {
                                output file /var/log/caddy/access.log
                                # Caddy's structured log format:
                                format json
                                # Or, for Common Log Format:
                                # format single_field common_log
                }
                owncloud.voncarmo.com {
                root * /www/local/www/owncloud
                file_server
                }

}

# Caddy will automatically obtain ACME certs for domains
# example.com {
#     root * /path/to/example.com

Each domain needs to be within its own site block, like this…

voncarmo.com {
                # Set this path to your site's directory:
                root * /usr/local/www/voncarmo.com

                # Enable the static file server:
                file_server

                # Set up a reverse proxy:
                # reverse_proxy localhost:8080

                # Serve a PHP site through php-fpm:
                # php_fastcgi localhost:9000
                php_fastcgi unix//var/run/php81.sock
                # Enable logging:
                log {
                                output file /var/log/caddy/access.log
                                # Caddy's structured log format:
                                format json
                                # Or, for Common Log Format:
                                # format single_field common_log
                }
}

owncloud.voncarmo.com {
                root * /www/local/www/owncloud
                file_server
}
1 Like

cheers… just needed to move that little sucker.

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