I’m actually facing the same issue.
I’m running a docker container just to explore how to add new sites using the API but I haven’t been able to make it work. So far I’ve tested the 2.0.0-alpine, 2.1.0-beta.1, and 2.1.0-beta.1-alpine images and seeing different behavior.
Note that I am running the container in port 8181
instead of port 80
.
Running docker:
$ docker run -d -p 8181:80 \
-p 2019:2019 \
-v $PWD/Caddyfile:/etc/caddy/Caddyfile \
-v caddy_data:/data \
caddy:2.1.0-beta.1-alpine
The contents of the Caddyfile
:
{
debug
admin 0.0.0.0:2019
}
localhost:2016 {
respond "Goodbye 2016!"
}
curl output:
curl http://localhost:2019/config -v ~/Development/CADDY/test
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 2019 (#0)
> GET /config HTTP/1.1
> Host: localhost:2019
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Content-Type: text/html; charset=utf-8
< Location: /config/
< Date: Thu, 25 Jun 2020 05:27:46 GMT
< Content-Length: 43
<
<a href="/config/">Moved Permanently</a>.
* Connection #0 to host localhost left intact
* Closing connection 0
If I curl http://localhost:8181
:
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8181 (#0)
> GET / HTTP/1.1
> Host: localhost:8181
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 308 Permanent Redirect
< Connection: close
< Location: https://localhost:2016/
< Server: Caddy
< Date: Thu, 25 Jun 2020 05:30:30 GMT
< Content-Length: 0
<
* Closing connection 0
Using the given Caddyfile
with caddy:2.0.0-alpine I would get the following error message:
$ docker exec c62cd caddy reload --config /etc/caddy/Caddyfile --adapter caddyfile ~/Development/CADDY/test
{"level":"info","ts":1593061662.197866,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
reload: sending configuration to instance: caddy responded with error: HTTP 403: {"error":"host not allowed: 0.0.0.0:2019"}