I am running caddy in a docker container.
# ./caddy version
v2.4.6 h1:HGkGICFGvyrodcqOOclHKfvJC0qTU7vny/7FhYp9hNw=
When I experiment with Caddyfiles, I run caddy validate
first and only then reload the Caddyfile.
My understanding is that there are atleast 3 ways (incl. API) to have caddy reload the Caddyfile without needing to restart it:
- Send the caddy instance a
USR1
: but when I do akill -USR1 1
inside the docker container where caddy’s PID is 1, I don’t see it reloading the Caddyfile (/root/.config/caddy/autosave.json remains the same).
# ps
PID USER TIME COMMAND
1 root 0:00 ./caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
-
./caddy reload --config /etc/caddy/Caddyfile --adapter caddyfile
results in an error:
reload: sending configuration to instance: performing request: Post "http://localhost:2019/load": dial tcp 127.0.0.1:2019: connect: connection refused
This is the stock /root/.config/caddy/autosave.json before reload
{"admin":{"disabled":true},"apps":{"http":{"servers":{"srv0":{"listen":[":443"],"logs":{"logger_names":{"example.com":"log0"},"skip_hosts":["www.example.com"]},"routes":[{"handle":[{"handler":"subroute","routes":[{"handle":[{"handler":"static_response","headers":{"Location":["https://example.com{http.request.uri}"]},"status_code":302}],"match":[{"host":["www.example.com"]}]}]}],"match":[{"host":["www.example.com"]}],"terminal":true},{"handle":[{"handler":"subroute","routes":[{"handle":[{"handler":"reverse_proxy","upstreams":[{"dial":"service_container:666"}]}]}]}],"match":[{"host":["example.com"]}],"terminal":true}]}}},"tls":{"automation":{"policies":[{"issuers":[{"challenges":{"dns":{"resolvers":["1.1.1.1"]}},"email":"admin@example.com","module":"acme"},{"challenges":{"dns":{"resolvers":["1.1.1.1"]}},"email":"admin@example.com","module":"zerossl"}],"subjects":["www.example.com","example.com"]}]}}},"logging":{"logs":{"default":{"exclude":["http.log.access.log0"]},"log0":{"include":["http.log.access.log0"],"level":"INFO"}}}}
This is the /root/.config/caddy/autosave.json I would expect to see after reload
{"admin":{"disabled":true},"apps":{"http":{"servers":{"srv0":{"listen":[":443"],"logs":{"logger_names":{"example.com":"log0"},"skip_hosts":["www.example.com"]},"routes":[{"handle":[{"handler":"subroute","routes":[{"handle":[{"handler":"static_response","headers":{"Location":["https://example.com{http.request.uri}"]},"status_code":302}],"match":[{"host":["www.example.com"]}]}]}],"match":[{"host":["www.example.com"]}],"terminal":true},{"handle":[{"handler":"subroute","routes":[{"group":"group1","handle":[{"handler":"rewrite","uri":"/legacy"}]},{"handle":[{"handler":"reverse_proxy","upstreams":[{"dial":"service_container:666"}]}]}]}],"match":[{"host":["example.com"]}],"terminal":true}]}}},"tls":{"automation":{"policies":[{"issuers":[{"challenges":{"dns":{"resolvers":["1.1.1.1"]}},"email":"admin@example.com","module":"acme"},{"challenges":{"dns":{"resolvers":["1.1.1.1"]}},"email":"admin@example.com","module":"zerossl"}],"subjects":["www.example.com","example.com"]}]}}},"logging":{"logs":{"default":{"exclude":["http.log.access.log0"]},"log0":{"include":["http.log.access.log0"],"level":"INFO"}}}}