On 2/12/25 17:25, Andreas Mock wrote:
http-request track-sc0 capture.req.hdr(0),lower,crc32c(1) => does work

So, my question: How can I construct a key consisting of both parts
in any way concatenated? Is is possible as a oneliner on

http-request track-sc0 <the stuff i need>

or do I have to do some intermediate variable assignment?

Any hint (or solution) would be very appreciated.



I don't think you can easily do it in one go, but you could do something on these lines:

* use `set-var-fmt` to set a string variable to concatenation of both the hostname and the source, something like:

http-request set-var-fmt(txn.track_key) "%[src] %[req.fhdr(host)]"

* then use your original idea to convert this string into a number with something like the `xxh3` converter and use that as the key of your table;


Note that `crc32c`, and even `xxh3` could lead to collisions, and if you use this for security purposes, then perhaps you should use `hmac` (see the documentation), or at least use the `xxh3(seed)` variant.

Also note, that by default track tables of type `integer` are 32 bit in size, thus if collisions are an issue, perhaps you should switch to `type binary len 16` (for 128 bits), and use the appropriate convertor.

Finally, don't forget to pay special attention to canonicalization of the concatenation, so that (if this is used for security purposes), the attacker can't spoof something via the `Host` header. (My proposal of `%[src] ...` should be OK.)



Reply via email to