Log-format %HU for http/2 requests logs full url (including protocol)

Hi!

I’m unsure whether this is a bug or me misunderstanding the documentation.

In haproxy 2.1.2:

According to the documentation, in log-format, %HU should be: HTTP request URI (ex: /foo?bar=baz)

But, for http/2 requests, the full url, including the protocol and hostname is logged instead (https://host/some/url, not /some/url, as I would expect).

For example:

log-format '{"host":"%[capture.req.hdr(0),json(ascii)]","url":"%{+E}HU"}'

Results in:

{"host":"example.com","url":"https://example.com/something"}

For HTTP/1.1 requests, the resulting url in the log is /something.

Is this something special with regards to how haproxy handles http/2 requests? And, what would be the easiest way to get the correct url into the log?

Hello!

I was wondering if you ever managed to figure this out?

I recently upgraded from 2.0 to 2.2 and am encountering the same issue, but using %r. The same happens where it logs the entire URI for http/2 requests, rather then just the path and query string.

Hi,
this change was introduced by this commit.

As of 2.2.3 you can use the pathq sample fetch to get the same result for both http 1 and http 2 as detailed in another post on this discourse.

I ended up using %{+E}[capture.req.uri], for example:

log-format '{"url":"%{+E}[capture.req.uri]","host":"%[capture.req.hdr(0),json(ascii)]"}'

Gotcha, thanks for the tip!

To replicate %r then I used this:

“%{-Q}[capture.req.method]\ %{-Q}[capture.req.uri]\ %{-Q}[capture.req.ver]”

capture.req.ver returns ‘-’ for http/2, but at least its consistent so that works for us.

Thanks!