Hi! I’m excited to start using caddy as a reverse proxy for my docker containers with docker compose, but after a few days of troubleshooting, I’m starting to think there may be an issue with the image that’s published to dockerhub. I’m running docker v19.03.5 and docker-compose v1.24.1 on macOS Catalina v10.15.2.
My Caddyfile
reads:
localhost
respond "Hello, world"
My docker-compose.yml
reads:
version: '3'
services:
caddy:
image: caddy/caddy:alpine
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
ports:
- "2015:2015"
I run docker-compose up
, which yields no errors. Then I run curl localhost:2015
, which gets no response but the server throws an error:
http.log.error strconv.Atoi: parsing "Hello, world": invalid syntax {"request": {"method": "GET", "uri": "/", "proto": "HTTP/1.1", "remote_addr": "192.168.16.1:39574", "host": "localhost:2015", "headers": {"Accept": ["*/*"], "User-Agent": ["curl/7.64.1"]}}, "status": 500, "err_id": "nq7jav3xm", "err_trace": "caddyhttp.StaticResponse.ServeHTTP (staticresp.go:114)"}
If I change the Caddyfile
's first line from localhost
to foo.local
and run docker-compose up
, it fails with the error:
run: loading initial config: loading new config: http app module: start: tcp: listening on :443: listen tcp :443: bind: permission denied
I’ve tried adding several combinations of ports to my docker-compose.yml
file to resolve this (although I would expect that if this were the problem, there would be no error and I simply wouldn’t be able to access caddy over port 443
): - "443:443"
, - "443:2015"
, - "2015:443"
and this has no effect.
I’ve also tried adding a capability to the service in my docker-compose file per some of the research on this forum I’ve done, which had no effect either:
services:
caddy:
...
cap_add:
- CAP_NET_BIND_SERVICE
When I try checking the version via docker-compose exec caddy caddy version
, it says simply (devel)
.
For context, my ultimate goal is to have 3 reverse proxied sites pointing to other docker containers running in my docker-compose file. In local development I’ll use x.mysite.local
, y.mysite.local
, and z.mysite.local
. In production I’ll use x.mysite.com
, y.mysite.com
, z.mysite.com
.
Is it me, or is there something wrong with the docker image?