Skip to content

Unable to parse caddy logs. #2814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mathias-ted opened this issue Mar 26, 2025 · 7 comments
Open

Unable to parse caddy logs. #2814

mathias-ted opened this issue Mar 26, 2025 · 7 comments

Comments

@mathias-ted
Copy link

mathias-ted commented Mar 26, 2025

Hello I am getting an error ipv4/6 is required while trying to parse caddy logs using the --log-format CADDY option.

Here is a sample of my logs:

2025/03/26 12:45:35.351	[34mINFO[0m	http.log.access.log0	handled request	{"request": {"remote_ip": "ziti-edge-router connId=2147483648, logical=ziti-sdk[router=tls:e1f3a989-daca-4ae9-8613-6046ea778240.production.netfoundry.io:443]", "remote_port": "", "client_ip": "", "proto": "HTTP/1.1", "method": "GET", "host": "hoer.share.zrok.io", "uri": "/", "headers": {"Accept-Language": ["en-US,en;q=0.9"], "Sec-Ch-Ua-Mobile": ["?1"], "Sec-Purpose": ["prefetch;prerender"], "X-Forwarded-Port": ["443"], "X-Forwarded-Proto": ["https"], "User-Agent": ["Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Mobile Safari/537.36"], "Sec-Fetch-User": ["?1"], "Sec-Fetch-Site": ["none"], "Sec-Ch-Ua": ["\"Not(A:Brand\";v=\"99\", \"Google Chrome\";v=\"133\", \"Chromium\";v=\"133\""], "Sec-Fetch-Dest": ["document"], "Sec-Fetch-Mode": ["navigate"], "Upgrade-Insecure-Requests": ["1"], "X-Amzn-Trace-Id": ["Root=1-67e3f6eb-2da76b630806088258a2bb07"], "X-Proxy": ["zrok"], "Priority": ["u=0, i"], "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.7"], "Accept-Encoding": ["gzip, deflate, br, zstd"], "Cookie": ["REDACTED"], "Purpose": ["prefetch"], "Sec-Ch-Ua-Platform": ["\"Android\""], "X-Forwarded-For": ["178.160.11.51, 100.32.0.1"]}}, "bytes_read": 0, "user_id": "", "duration": 1.2035587, "size": 0, "status": 302, "resp_headers": {"Server": ["Caddy", "Kestrel"], "Content-Length": ["0"], "Date": ["Wed, 26 Mar 2025 12:45:35 GMT"], "Location": ["web/"]}}


2025/03/26 12:45:49.606	[34mINFO[0m	http.log.access.log0	handled request	{"request": {"remote_ip": "ziti-edge-router connId=2147483649, logical=ziti-sdk[router=tls:f12da3a5-c651-4dbe-ace0-67723a5dda65.production.netfoundry.io:443]", "remote_port": "", "client_ip": "", "proto": "HTTP/1.1", "method": "GET", "host": "hoer.share.zrok.io", "uri": "/web/37869.088680d7e7a2eede3618.css?22b44eb501cfeefd535d", "headers": {"Accept-Encoding": ["gzip, deflate, br, zstd"], "Sec-Ch-Ua-Mobile": ["?1"], "Accept-Language": ["en-US,en;q=0.9"], "Sec-Fetch-Mode": ["no-cors"], "Sec-Fetch-Site": ["same-origin"], "X-Forwarded-For": ["178.160.11.51, 100.32.0.1"], "User-Agent": ["Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Mobile Safari/537.36"], "Accept": ["text/css,*/*;q=0.1"], "Cookie": ["REDACTED"], "Sec-Ch-Ua-Platform": ["\"Android\""], "Sec-Fetch-Dest": ["style"], "Sec-Purpose": ["prefetch;prerender"], "X-Amzn-Trace-Id": ["Root=1-67e3f6f9-7ef2d2d72148632f0cc5ce40"], "X-Forwarded-Proto": ["https"], "Priority": ["u=0"], "Purpose": ["prefetch"], "Sec-Ch-Ua": ["\"Not(A:Brand\";v=\"99\", \"Google Chrome\";v=\"133\", \"Chromium\";v=\"133\""], "X-Forwarded-Port": ["443"], "X-Proxy": ["zrok"]}}, "bytes_read": 0, "user_id": "", "duration": 2.5090096, "size": 23113, "status": 200, "resp_headers": {"Date": ["Wed, 26 Mar 2025 12:45:49 GMT"], "Content-Encoding": ["br"], "Content-Type": ["text/css"], "Server": ["Caddy", "Kestrel"], "Vary": ["Accept-Encoding"], "X-Response-Time-Ms": ["2024.427"], "Accept-Ranges": ["bytes"], "Etag": ["\"1db3a3661bcfffc\""], "Last-Modified": ["Tue, 19 Nov 2024 03:51:58 GMT"]}}

Here is the screenshot of the error I am receiving.

Image

@mathias-ted mathias-ted changed the title Unable to pass caddy logs. Unable to parse caddy logs. Mar 26, 2025
@allinurl
Copy link
Owner

The issue is that the Caddy logs need to be in JSON format. Currently, your logs are a mix of timestamped entries with additional information followed by JSON. To ensure the logs are consistently in JSON format, update your Caddy configuration file as follows:

format json {
    time_format iso8601
}

@mathias-ted
Copy link
Author

I have updated but still getting the same error ipv4/6 required

Here is my caddyfile config

http:// {
bind {{ .ZrokBindAddress }}
log {
output file "C:/Program Files/Zrok/server.log"
format json {
time_format iso8601
}

}
reverse_proxy 127.0.0.1:2000

}

@allinurl
Copy link
Owner

Can you please post a few lines from your log?

@mathias-ted
Copy link
Author

mathias-ted commented Mar 26, 2025

{"level":"info","ts":1743003163.1276934,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"ziti-edge-router connId=2147483679, logical=ziti-sdk[router=tls:e1f3a989-daca-4ae9-8613-6046ea778240.production.netfoundry.io:443]","remote_port":"","client_ip":"","proto":"HTTP/1.1","method":"GET","host":"hoer.share.zrok.io","uri":"/web/serviceworker.js","headers":{"Sec-Fetch-Mode":["same-origin"],"X-Proxy":["zrok"],"Cookie":["REDACTED"],"Referer":["https://hoer.share.zrok.io/web/serviceworker.js"],"X-Forwarded-For":["132.208.246.216, 100.32.2.68"],"X-Forwarded-Port":["443"],"User-Agent":["Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Mobile Safari/537.36"],"Cache-Control":["max-age=0"],"Priority":["u=4, i"],"Sec-Fetch-Dest":["serviceworker"],"Sec-Fetch-Site":["same-origin"],"Service-Worker":["script"],"Accept-Language":["en-US,en;q=0.9"],"Accept-Encoding":["gzip, deflate, br, zstd"],"If-Modified-Since":["Tue, 19 Nov 2024 03:51:58 GMT"],"If-None-Match":["\"1db3a3661bd4000\""],"X-Amzn-Trace-Id":["Root=1-67e41e19-3fceba971e058d8a142ce387"],"X-Forwarded-Proto":["https"],"Accept":["*/*"]}},"bytes_read":0,"user_id":"","duration":0.0018956,"size":0,"status":304,"resp_headers":{"X-Response-Time-Ms":["0.5905"],"Server":["Caddy","Kestrel"],"Content-Type":["text/javascript"],"Date":["Wed, 26 Mar 2025 15:32:42 GMT"],"Accept-Ranges":["bytes"],"Etag":["\"1db3a3661bd4000\""],"Last-Modified":["Tue, 19 Nov 2024 03:51:58 GMT"]}}

{"level":"info","ts":1743003156.7471795,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"ziti-edge-router connId=2147483677, logical=ziti-sdk[router=tls:ad2b1ffe-8cee-465d-b3fc-8d1100bb5f32.production.netfoundry.io:443]","remote_port":"","client_ip":"","proto":"HTTP/1.1","method":"POST","host":"hoer.share.zrok.io","uri":"/DisplayPreferences/usersettings?userId=c2e5b089a6b24b96ac10902d574f6898&client=emby","headers":{"Accept":["*/*"],"Cookie":["REDACTED"],"Sec-Ch-Ua":["\"Not(A:Brand\";v=\"99\", \"Google Chrome\";v=\"133\", \"Chromium\";v=\"133\""],"Sec-Fetch-Mode":["cors"],"User-Agent":["Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Mobile Safari/537.36"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Content-Type":["application/json"],"X-Amzn-Trace-Id":["Root=1-67e41e13-0092f73e7dd2c2bf05aa9515"],"X-Forwarded-For":["132.208.246.216, 100.32.2.68"],"X-Proxy":["zrok"],"Content-Length":["1540"],"Accept-Language":["en-US,en;q=0.9"],"X-Forwarded-Port":["443"],"X-Forwarded-Proto":["https"],"Authorization":["REDACTED"],"Origin":["https://hoer.share.zrok.io"],"Priority":["u=1, i"],"Sec-Ch-Ua-Mobile":["?1"],"Sec-Ch-Ua-Platform":["\"Android\""],"Sec-Fetch-Dest":["empty"],"Sec-Fetch-Site":["same-origin"]}},"bytes_read":1540,"user_id":"","duration":0.0587683,"size":0,"status":204,"resp_headers":{"X-Response-Time-Ms":["57.442"],"Date":["Wed, 26 Mar 2025 15:32:35 GMT"],"Server":["Caddy","Kestrel"],"Access-Control-Allow-Origin":["*"]}}

@allinurl
Copy link
Owner

are you able to validate those json logs? it should pass the test.

https://jsonlint.com/

@mathias-ted
Copy link
Author

mathias-ted commented Mar 27, 2025

Yes it has passed the test , json is valid.

@allinurl
Copy link
Owner

There's no valid IP on your log, you have: remote_ip":"ziti-edge-router connId=2147483677, logical=ziti-sdk[router=tls:ad2b1ffe-8cee-465d-b3fc-8d1100bb5f32.production.netfoundry.io:443. your client_ip is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants