Logging http headers for debugging

Is it possible to use Caddy as a proxy to log all HTTP headers coming in to a URL? I would like to throw a caddy server up for debugging of an already existing service that I’m having issues with, and would like to inspect the http headers coming in before going to this service.

All the headers on a single line? Hmm, I don’t know that you can right now, but we could look into adding that. What do you want it to look like? (i.e. how do you want to delimit the fields?)

1 Like

Hello @matt.

I have no idea, honestly. I would say that if it showed something similar to:

Header: Value
Header-2: Value-2

I’d be happy enough with it. I don’t want to, nor intend to use it for production, but for this issue, it’s giving us headaches in development that we need to ensure we’re getting the headers in the right way without having to dig too deeply into the internals of the app we’re hosting. At least for my use case, I don’t need much formatting at all beyond being able to tell what each header/value pair was at a particular timestamp.

A log entry that spans multiple lines? Are you sure you wouldn’t want it on a single line?

1 Like

I would take whatever. I just don’t know how you’d separate header fields, which is why I just separated by lines. I’m sure I could whip up a one-liner in awk or something, so I’d be okay with either.

I think we should try to keep it to one line.

There’s a way, in Go, to dump the details of a request: httputil package - net/http/httputil - pkg.go.dev - however, this writes line breaks.

@klauern Would you like to open an issue to request this feature? Link to this thread.

1 Like

Done: https://github.com/mholt/caddy/issues/858

1 Like