1. Caddy version (caddy version
):
v2.4.6
2. How I run Caddy:
Defined as a service in docker-compose.yml. see below
a. System environment:
b. Command:
docker-compose up -d
c. Service/unit/compose file:
caddy:
image: caddy:2-alpine
restart: unless-stopped
depends_on:
- laravel-api
- nextjs-platform
- nextjs-shop
ports:
- "80:80"
- "443:443"
- "2019:2019"
volumes:
- ./docker/dev/caddy/Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
- caddy_config:/config
volumes:
caddy_data:
external: true
caddy_config:
d. My complete Caddyfile or JSON config:
{
debug
admin :2019
}
localhost:80 {
reverse_proxy nextjs-platform:3000
reverse_proxy /api/* {
to laravel-api:8000
}
}
{http.request.host}.localhost:80 {
reverse_proxy nextjs-shop:3000
reverse_proxy /api/* laravel-api:8000
}
# These should go to 404 page cause deployment doesnt exist
# new deployments are added over api
*.localhost:80 {
@try_files {
not path /_next/* /logo.svg
file {
try_files {path} /
}
}
# Redirect to the deployment not found page
rewrite @try_files /deployment_not_found
reverse_proxy nextjs-platform:3000
}
3. The problem I’m having:
I run a job that when a new deployment is executed it places a put request to http://caddy:2019/config/apps/http/servers/srv0/routes/0/match/0/host/0
which works fine to add a new host and I can see the new host show up in the /config/caddy/autosave.json
However when i restart or down my docker-compose services I lose the autosave.json
(Doesnt persist?)
4. Error messages and/or full log output:
None it all works except I lose my autosave.json on restart
5. What I already tried:
I’ve also tried mounting the volumes differently for example:
volumes:
- ./docker/dev/caddy/Caddyfile:/etc/caddy/Caddyfile
- ./docker/dev/caddy/caddy_data:/data
- ./docker/dev/caddy/caddy_config:/config
Which are paths in my current project directory but in that case I dont even see the autosave.json
get created when I exec caddy /bin/sh
and go to /config/caddy