1. Caddy version:
v2.4.3 h1:Y1FaV2N4WO3rBqxSYA8UZsZTQdN+PwcoOcAiZTM8C0I=
2. How I installed, and run Caddy:
docker
a. System environment:
Docker on Ubuntu 20.20
c. Service/unit/compose file:
#
# Production frontend and backend and docs
#
# PYramid backend API server is localhost:3456
# SvelteKit Node.js frontend SSR server is localhost:3000
#
http://example.com {
# Backend API request
handle /api* {
# This is the upstream Waitress server
reverse_proxy 127.0.0.1:3456 {
# Backend API must respond to an individual API call under 20s seconds
transport http {
response_header_timeout 20s
}
}
}
# Special URL endpoint for Google and other bots
# that are robots.txt blocked from API
handle_path /sitemap/* {
# Same as /api, just a path rewrite using Caddy handle_path
# https://webinstall.dev/caddy/
rewrite * /api{path}
reverse_proxy 127.0.0.1:3456
}
# Serve docs as files rsync'ed to the server
# See trading-strategy/.github/workflows/rsync-docs.yml for more details
# https://caddy.community/t/caddy-file-server-browse-not-working-when-root-a-specific-directory/15342/3
redir /docs /docs/
handle_path /docs* {
# See docker-compose
# mapped to /home/docs/html
root * /docs
file_server
}
# SvelteKit production server from frontend repository
handle {
reverse_proxy 127.0.0.1:3000 {
header_up X-Forwarded-Host {host}
# Frontend must render the page under 20 seconds
transport http {
response_header_timeout 20s
}
}
}
# Set the default 404 page
# https://caddyserver.com/docs/caddyfile/directives/handle_errors
handle_errors {
respond "{http.error.status_code} {http.error.status_text}"
}
# Create a log file log {
format json
output file /var/log/caddy/access.log
#output stdout
# Caddy cannot have two log outputs at the same time
}
}
3. The problem I’m having:
I am grepping through Caddy JSON access logs and sometimes I see HTTP status code (status
field) set to zero. What does this mean?
4. Error messages and/or full log output:
Caddy log JSON object:
{"level":"info","ts":1674820082.9167147,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_addr":"zzzzz,"proto":"HTTP/1.1","method":"GET","host":"tradingstrategy.ai","uri":"zzzzzzz","headers":{"Cdn-Loop":["cloudflare"],"Accept-Encoding":["gzip"],"Cf-Visitor":["{\"scheme\":\"https\"}"],"Cf-Ipcountry":["SG"],"Cf-Connecting-Ip":["zzzzz"],"Connection":["Keep-Alive"],"X-Forwarded-For":["139.180.132.162"],"Cf-Ray":["790141cc89a86c06-SIN"],"X-Forwarded-Proto":["https"]}},"common_log":"zzzzz - - [27/Jan/2023:11:48:02 +0000] \"GET /api/zzzzz HTTP/1.1\" 0 0","duration":0.00009558,"size":0,"status":0,"resp_headers":{"Server":["Caddy"]}}```
5. What I already tried:
Google.