Parse error: Unknown directive

Working on my Caddy integration into my LEMP stack, and I have setup

/etc/caddy/Caddyfile as

import ./conf.d/*

with contents of /etc/caddy/conf.d directory as

ls -lah /etc/caddy/conf.d
total 12K
drwxr-xr-x 2 root root    87 Aug  6 01:54 .
drwxr-xr-x 3 root nginx   35 Aug  6 00:03 ..
-rw-r--r-- 1 root root   760 Aug  6 00:06 host.domain1.com.conf
-rw-r--r-- 1 root root   787 Aug  6 02:02 domain1.com.conf

contents of host.domain1.com.conf which works and starts Caddy fine

curl -I host.domain1.com:81
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: max-age=86400
Content-Length: 3801
Content-Type: text/html; charset=utf-8
Etag: W/"579b144d-ed9"
Last-Modified: Fri, 29 Jul 2016 08:31:09 GMT
Server: Caddy
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
Date: Sat, 06 Aug 2016 01:41:41 GMT
host.domain1.com:81 {
    gzip {
        level 6
        min_length 1400
    }
    browse
    header / {
        Cache-Control "max-age=86400"
        X-Content-Type-Options "nosniff"
        X-Frame-Options "SAMEORIGIN"
        X-XSS-Protection "1; mode=block"
        #-Server
    }   
    tls off
    root /usr/local/nginx/html
    fastcgi / 127.0.0.1:9000 {
        ext   .php
        split .php
        index index.php
    }
    log / /usr/local/nginx/logs/centos7.localdomain-access.log "{remote} {when} {method} {uri} {proto} {status} {size} {>User-Agent} {latency}" {
        rotate {
                size 100 # Rotate after 100 MB
                age  14  # Keep log files for 14 days
                keep 10  # Keep at most 10 log files
        }
    }

contents of domain1.com.conf which when added Caddy fails to start

domain1.com:81 {
    gzip {
        level 6
        min_length 1400
    }
    browse
    header / {
        Cache-Control "max-age=86400"
        X-Content-Type-Options "nosniff"
        X-Frame-Options "SAMEORIGIN"
        X-XSS-Protection "1; mode=block"
        #-Server
    }   
    tls off
    root /home/nginx/domains/domain1.com/public
    fastcgi / 127.0.0.1:9000 {
        ext   .php
        split .php
        index index.php
    }
    log / /home/nginx/domains/domain1.com/log/caddy-domain1.com-access.log "{remote} {when} {method} {uri} {proto} {status} {size} {>User-Agent} {latency}" {
        rotate {
                size 100 # Rotate after 100 MB
                age  14  # Keep log files for 14 days
                keep 10  # Keep at most 10 log files
        }
    }

with domain1.com.conf vhost file Caddy gives me ??

2016/08/06 02:02:02 domain1.com.conf:1 - Parse error: Unknown directive 'domain1.com:81'

what am I missing ?

A closing } in both of your files :wink:

1 Like

ah ha those pesky curly brackets !!

looks like it’s working so far :slight_smile:

/root/tools/caddy.sh status 
caddy is running (8410)
-----------------------------------------------
Max processes     8192     8192     processes 
Max open files    262144   262144   files 
-----------------------------------------------

addsite option

/root/tools/caddy.sh addsite       

enter domain name wihtout www.: domain1.com

/etc/caddy/conf.d/domain1.com.conf created on 8888
/etc/caddy/conf.d/domain1.com.ssl.conf created on 448

options

/root/tools/caddy.sh

Command Usage: 
/root/tools/caddy.sh {install|update|uninstall|addsite|start|stop|restart|status|domains|certs|version|help}
1 Like

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