Caddyfile:4 - Parse error: Unknown directive ''


I try to offer a download directory on a docker run image.

The problem is that I get always this error when I add the virtual host.

Caddyfile:4 - Parse error: Unknown directive ‘


FROM abiosoft/caddy:latest
ADD containerfiles/ /
WORKDIR /my-portal



# 2016/09/20 19:43:23 Caddyfile:4 - Parse error: Unknown directive ‘
# {
# root /download
# browse

log stdout
errors stdout

I have read The Caddyfile — Caddy Documentation but I’m sure I have missed something.
The is currently not resolvable, could be this a problem?

Thanks for help

You have the same problem as this guy, where you missed this:

To configure multiple servers (virtual hosts) with a single Caddyfile, you must use curly braces around each site block.

And if you want to serve your site over HTTPS, the domain must resolve.

Thanks matt I thought something like this.

My solution is now this.

http://:2015 {
redir 301 {
if {path} not_match ^/download.*

log stdout

errors stdout

/download {
tls off
root /download

but currently i get this message back.

2016/09/20 21:26:30 Caddyfile:4 - Parse error: Wrong argument count or unexpected line ending after ‘/download.*’

I’m still reading the docs to find the right syntax.

When I understand the example right in then the syntax which I use should work.
What have I missed?

I don’t need ssl for this setup.

That’s strange, that Caddyfile works for me…

is there a debug option in caddy?

That does what?

Well print out why the file does not work :wink:

I will dig further and tell you what I have found.

I’m suspicious that what you’ve posted here isn’t what your actual Caddyfile is, since /download.* doesn’t appear on line 4 of your Caddyfile.

The problem was the permission in the used Image.

I have created one with rhel7, you can also use centos or some other distributions.

I think when in the caddy-docker/Dockerfile at master · abiosoft/caddy-docker · GitHub the USER command is removed the image could also work on openshift.

I have decided to build my own because I have also add some more plugins and moved the caddyfile to /etc/caddy.
The caddyfile in /etc/caddy make it possible to use configmaps ( ConfigMaps | Developer Guide | OpenShift Enterprise 3.2 ) in openshift.

Thanks to @abiosoft for the Dockerfile, based on yours I was able to run create my own really fast.

The only problem which I still have is that I have no log entry for /download only for the first block.
Any idea?

Your site definition doesn’t have a log directive in it.

You can start the container with root user to bypass volume mount permissions. e.g. using docker run, docker run --user root abiosoft/caddy

I thought this is it

The site is

http://:2015 { …}


/download {…}

I have add log in both blocks. is this wrong?

Nope. The openshiftt runs docker for me so I have no option to add such a parameter to the docker.

Finally I have the following working config.

http://:2015 {
redir 301 {
if {path} not_match ^/download.*
/ https://{$REDIR_DOMAIN}/

realip {

log stdout
errors stdout

tls off

My misunderstanding was that I thought a ‘/’ in the same address could have a own settings block.
After several reading round on The Caddyfile — Caddy Documentation I came to the conclusion that this makes no sense.

Now one of my targets was solved, next is waiting in the queue :wink:

1 Like

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