1. Caddy version (caddy version
):
Latest (gets downloaded on Docker build)
2. How I run Caddy:
caddy run --config /app/Caddyfile
a. System environment:
Laravel environment I’m trying to run inside Docker.
b. Command:
paste command here
c. Service/unit/compose file:
Relevant Dockerfile part:
FROM php:8.0.3
# Caddy server
RUN curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | apt-key add -
RUN curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee -a /etc/apt/sources.list.d/caddy-stable.list
RUN apt-get update -y && apt-get install caddy
...
CMD caddy run --config /app/Caddyfile
Dockerfile:
version: '3.5'
services:
api:
build:
context: ./api
dockerfile: Dockerfile
ports:
- "8080:8080"
volumes:
- ./api:/app/
depends_on:
- db
d. My complete Caddyfile or JSON config:
http://0.0.0.0:8080 {
root * /app/public
log
encode gzip
file_server
}
3. The problem I’m having:
I get absolutely no error (please check next part), only an empty content. I was expecting at least a 500 error from Laravel.
I don’t use FastCGI nor FPM because this project is a small blog API, not aiming to reach 10k visitors a day, so I didn’t feel the need to use any of those. Please tell me if I’m wrong / stupid.
I also don’t want HTTPS since HTTPS will be available from a Traefik reverse proxy when my website will go to production.
4. Error messages and/or full log output:
docker-compose logs api
Attaching to siteweb_api_1
api_1 | {"level":"info","ts":1615755327.2930388,"msg":"using provided configuration","config_file":"/app/Caddyfile","config_adapter":""}
api_1 | {"level":"info","ts":1615755327.298195,"logger":"admin","msg":"admin endpoint started","address":"tcp/localhost:2019","enforce_origin":false,"origins":["localhost:2019","[::1]:2019","127.0.0.1:2019"]}
api_1 | {"level":"info","ts":1615755327.2983677,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc0003dd490"}
api_1 | {"level":"info","ts":1615755327.299239,"logger":"tls","msg":"cleaned up storage units"}
api_1 | {"level":"info","ts":1615755327.299237,"msg":"autosaved config","file":"/root/.config/caddy/autosave.json"}
api_1 | {"level":"info","ts":1615755327.2992644,"msg":"serving initial configuration"}
api_1 | {"level":"info","ts":1615755336.061243,"logger":"http.log.access","msg":"handled request","request":{"remote_addr":"172.23.0.1:46622","proto":"HTTP/1.1","method":"GET","host":"localhost:8080","uri":"/","headers":{"Connection":["keep-alive"],"Cookie":["__stripe_mid=09a24952-fb81-4bbb-a250-e2e496522237; Phpstorm-765b08c8=6b43f34d-7868-46b8-85bb-c8b3d4c6264f; i18n_redirected=fr"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"],"Accept-Language":["fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3"],"Accept-Encoding":["gzip, deflate"]}},"common_log":"172.23.0.1 - - [14/Mar/2021:20:55:36 +0000] \"GET / HTTP/1.1\" 0 0","duration":0.000003241,"size":0,"status":0,"resp_headers":{"Server":["Caddy"]}}
api_1 | {"level":"info","ts":1615755337.5498781,"logger":"http.log.access","msg":"handled request","request":{"remote_addr":"172.23.0.1:46622","proto":"HTTP/1.1","method":"GET","host":"localhost:8080","uri":"/","headers":{"Accept-Encoding":["gzip, deflate"],"Connection":["keep-alive"],"Cookie":["__stripe_mid=09a24952-fb81-4bbb-a250-e2e496522237; Phpstorm-765b08c8=6b43f34d-7868-46b8-85bb-c8b3d4c6264f; i18n_redirected=fr"],"Cache-Control":["max-age=0"],"Accept-Language":["fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3"],"User-Agent":["Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"],"Upgrade-Insecure-Requests":["1"]}},"common_log":"172.23.0.1 - - [14/Mar/2021:20:55:37 +0000] \"GET / HTTP/1.1\" 0 0","duration":0.000003757,"size":0,"status":0,"resp_headers":{"Server":["Caddy"]}}
api_1 | {"level":"info","ts":1615755581.5253675,"logger":"http.log.access","msg":"handled request","request":{"remote_addr":"172.23.0.1:47648","proto":"HTTP/1.1","method":"GET","host":"localhost:8080","uri":"/","headers":{"Connection":["keep-alive"],"Cookie":["__stripe_mid=09a24952-fb81-4bbb-a250-e2e496522237; Phpstorm-765b08c8=6b43f34d-7868-46b8-85bb-c8b3d4c6264f; i18n_redirected=fr"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"],"Accept-Language":["fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3"],"Accept-Encoding":["gzip, deflate"]}},"common_log":"172.23.0.1 - - [14/Mar/2021:20:59:41 +0000] \"GET / HTTP/1.1\" 0 0","duration":0.000003752,"size":0,"status":0,"resp_headers":{"Server":["Caddy"]}}
5. What I already tried:
I’ve seen quite a lot of subjects having this kind of problem, but their answers didn’t sove mine.
I tried to copy some other people’s configuration, but no success so far
6. Links to relevant resources:
Thank you in advance