1. Caddy version (caddy version
):
v2.2.1
2. How I run Caddy:
a. System environment:
ARG CADDY_VERSION=2.2.1
FROM caddy:${CADDY_VERSION}-builder-alpine AS builder
ARG ROUTE53_VERSION=1.0.2
RUN xcaddy build \
--with github.com/caddy-dns/route53@v${ROUTE53_VERSION}
FROM caddy:${CADDY_VERSION}-alpine
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
RUN apk --no-cache add curl
ENV XDG_DATA_HOME=/data \
XDG_CONFIG_HOME=/config
COPY static/root /
CMD ["scaddy"]
b. Command:
This is the scaddy
bash script referenced in the Dockerfile.
APP_BASIC_AUTH_PASSWORD_HASHED=$(caddy hash-password --plaintext $APP_BASIC_AUTH_PASSWORD) KUEUI_BASIC_AUTH_PASSWORD_HASHED=$(caddy hash-password --plaintext $KUEUI_BASIC_AUTH_PASSWORD) FARCRY_BASIC_AUTH_PASSWORD_HASHED=$(caddy hash-password --plaintext $FARCRY_BASIC_AUTH_PASSWORD) caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
c. Service/unit/compose file:
d. My complete Caddyfile or JSON config:
{$APP_DOMAIN} {
encode gzip
log {
output stdout
format filter {
wrap json {
message_key "message"
level_key "severity"
time_key "timestampSeconds"
}
fields {
common_log delete
}
}
level DEBUG
}
root * /www/admin
file_server
@exceptProxy not path /css/* /fonts/* /images/* /js/* /favicon.ico /robots.txt /version.json
reverse_proxy @exceptProxy http://app:{$APP_SERVICE_PORT_HTTP}
}
3. The problem Iām having:
Iām trying to structure the JSON logs to match the specified JSON at GeraĆ§Ć£o de registros estruturados Ā |Ā Cloud Logging Ā |Ā Google Cloud. This helps with automatic Log ingestion when running on GKE.
4. Error messages and/or full log output:
The closest I can get to is:
{
"level": "info",
"timestampSeconds": 1622762635.692175,
"logger": "http.log.access.log173",
"message": "handled request",
"request": {
"remote_addr": "172.17.0.1:19853",
"proto": "HTTP/2.0",
"method": "GET",
"host": "www.typicalmotors.local.repcoservice.net",
"uri": "/",
"headers": {
"Accept-Encoding": ["gzip, deflate, br"],
"Cookie": [
"_ga=GA1.2.262521322.1622506095; _gid=GA1.2.1926935137.1622598217"
],
"Cp-Extension-Installed": ["Yes"],
"Accept": [
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
],
"Sec-Fetch-Site": ["none"],
"Sec-Fetch-Dest": ["document"],
"Sec-Fetch-Mode": ["navigate"],
"Accept-Language": ["en-AU,en;q=0.9,en-US;q=0.8"],
"Sec-Ch-Ua": [
"\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\""
],
"Sec-Ch-Ua-Mobile": ["?0"],
"Upgrade-Insecure-Requests": ["1"],
"Cache-Control": ["max-age=0"],
"Authorization": ["Basic Y2hhc3Npczp4QkJCYWlZWFhGYW5QRHhoN1lLZEZmdFU="],
"User-Agent": [
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36"
],
"Sec-Fetch-User": ["?1"]
},
"tls": {
"resumed": false,
"version": 772,
"cipher_suite": 4865,
"proto": "h2",
"proto_mutual": true,
"server_name": "www.typicalmotors.local.repcoservice.net"
}
},
"duration": 5.391735864,
"size": 14852,
"status": 200,
"resp_headers": {
"Server": ["Caddy"],
"Link": [
"<https://www.typicalmotors.local.repcoservice.net/>; rel=\"canonical\""
],
"Content-Type": ["text/html; charset=utf-8"],
"Etag": ["\"eee8-BffRLbLiGMWHIMVYKUw4WkXAIWI\""],
"Content-Encoding": ["gzip"],
"Date": ["Thu, 03 Jun 2021 23:23:55 GMT"],
"X-Powered-By": ["Next.js"],
"Cache-Control": [
"private, no-cache, no-store, max-age=0, must-revalidate"
],
"Vary": ["Accept-Encoding"]
}
}
Notice that level_key
didnāt get rewritten?
There is a bunch of other things I want to do like rename request
to httpRequest
, and then request>method
to httpRequest>requestMethod
, etc.
Is this possible?
Iāve read through the logs a few times but I canāt find anything.
Any advice would be appreciated. Thanks.