Hi.
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 ‘download.my-domain.com ’
Dockerfile
FROM abiosoft/caddy:latest
EXPOSE 2015
ADD containerfiles/ /
WORKDIR /my-portal
Caddyfile.
:2015
# 2016/09/20 19:43:23 Caddyfile:4 - Parse error: Unknown directive ‘download.my-domain.com ’
# download.my-domain.com {
# root /download
# browse
#}
redir https://cloud.my-domain.com/
log stdout
errors stdout
I have read The Caddyfile — Caddy Documentation but I’m sure I have missed something.
The download.my-domain.com is currently not resolvable, could be this a problem?
Thanks for help
matt
(Matt Holt)
September 20, 2016, 8:20pm
2
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.*
/ https://cloud.my-domain.com/
}
log stdout
errors stdout
}
/download {
tls off
root /download
browse
}
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 https://caddyserver.com/docs/redir then the syntax which I use should work.
What have I missed?
I don’t need ssl for this setup.
matt
(Matt Holt)
September 21, 2016, 12:57am
4
That’s strange, that Caddyfile works for me…
is there a debug option in caddy?
Well print out why the file does not work
I will dig further and tell you what I have found.
matt
(Matt Holt)
September 22, 2016, 6:04pm
8
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.
https://github.com/cw-aleks/caddy-on-openshift
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?
matt
(Matt Holt)
September 22, 2016, 7:29pm
10
Your site definition doesn’t have a log directive in it.
abiosoft
(Abiola Ibrahim)
September 22, 2016, 7:31pm
11
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
https://github.com/cw-aleks/caddy-on-openshift/blob/master/containerfiles/etc/caddy/caddyfile#L11+L24
The site is
http://:2015 { …}
and
/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 {
from 10.0.0.0/8
}
log stdout
errors stdout
gzip
tls off
root {$DOWNLOAD_DIR}
browse
}
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
1 Like
system
(system)
Closed
December 24, 2016, 7:44am
15
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.