1. The problem I’m having:
HTTP Error 404
2. Error messages and/or full log output:
2024-03-12 15:14:30 {"level":"info","ts":1710227670.7920194,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
2024-03-12 15:14:30 {"level":"warn","ts":1710227670.7925587,"msg":"Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":1}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.7933304,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.7934408,"logger":"http.auto_https","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"srv0","https_port":443}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.7934673,"logger":"http.auto_https","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.7935898,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000419500"}
2024-03-12 15:14:30 {"level":"warn","ts":1710227670.798147,"logger":"tls","msg":"storage cleaning happened too recently; skipping for now","storage":"FileStorage:/data/caddy","instance":"5f458cdb-da79-4d2a-9146-38bb02bc2fe5","try_again":1710314070.7981458,"try_again_in":86399.9999997}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.7982256,"logger":"tls","msg":"finished cleaning storage units"}
2024-03-12 15:14:30 {"level":"warn","ts":1710227670.8294501,"logger":"pki.ca.local","msg":"installing root certificate (you might be prompted for password)","path":"storage:pki/authorities/local/root.crt"}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.83146,"msg":"warning: \"certutil\" is not available, install \"certutil\" with \"apt install libnss3-tools\" or \"yum install nss-tools\" and try again"}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.831504,"msg":"define JAVA_HOME environment variable to use the Java trust"}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.8676543,"msg":"certificate installed properly in linux trusts"}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.8680847,"logger":"http.log","msg":"server running","name":"remaining_auto_https_redirects","protocols":["h1","h2","h3"]}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.8681805,"logger":"http","msg":"enabling HTTP/3 listener","addr":":443"}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.8683345,"msg":"failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/quic-go/quic-go/wiki/UDP-Buffer-Sizes for details."}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.868477,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.868504,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["localhost"]}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.868777,"logger":"tls.obtain","msg":"acquiring lock","identifier":"localhost"}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.8690805,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.869109,"msg":"serving initial configuration"}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.8717136,"logger":"tls.obtain","msg":"lock acquired","identifier":"localhost"}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.8718152,"logger":"tls.obtain","msg":"obtaining certificate","identifier":"localhost"}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.8732607,"logger":"tls.obtain","msg":"certificate obtained successfully","identifier":"localhost"}
2024-03-12 15:14:30 {"level":"info","ts":1710227670.8733213,"logger":"tls.obtain","msg":"releasing lock","identifier":"localhost"}
2024-03-12 15:14:30 {"level":"warn","ts":1710227670.8734894,"logger":"tls","msg":"stapling OCSP","error":"no OCSP stapling for [localhost]: no OCSP server specified in certificate","identifiers":["localhost"]}
3. Caddy version:
FROM caddy:2.7.6-alpine
4. How I installed and ran Caddy:
a. System environment:
Docker swarm, Docker v4.28.0 on Windows 11
b. Command:
=== docker build and push ===
docker build -f caddy.dockerfile -t andrewwang1tw/micro-caddy:1.0.2 .
docker push andrewwang1tw/micro-caddy:1.0.2
=== docker swarm init and deploy ===
docker swarm init
docker stack deploy -c swarm.yml myapp
c. Service/unit/compose file:
Docker file and Docker swarm file
==- Docker file ===
FROM caddy:2.7.6-alpine
COPY Caddyfile /etc/caddy/Caddyfile
=== Docker swarm file =====
version: '3'
services:
caddy:
image: andrewwang1tw/micro-caddy:1.0.2
deploy:
mode: replicated
replicas: 1
ports:
- "80:80"
- "443:443"
volumes:
- caddy_data:/data
- caddy_config:/config
volumes:
caddy_data:
external: true
caddy_config:
d. My complete Caddy config:
localhost
respond "Hello, world!"