with [HTTP::header “target”] I am able to get the basic stuff like User-Agent. Is there separate command to grab x-header information for logging purpose?
You can iterate through the header names and look for a header name that starts with x- and then log the header name and value.
Here’s an example:
when HTTP_REQUEST {
initializes a variable to store the headers
set headers
loop through the header names
foreach aHeader [HTTP::header names] {
check if this header starts with x-
if {[string tolower $aHeader] starts_with "x-"}{
add the header name and value to the headers variable
set headers "$headers; $aHeader: [HTTP::header value $aHeader]"
}
}
if {$headers}{
log local0. "client: [IP::client_addr]; x- headers: $headers"
}
}
This assumes that there is only one instance of each header name. If you want to log multiple values of the same header name, try checking the HTTP::header page for info on HTTP::header values (Click here).
Aaron