Forum Discussion

FrontmanFin's avatar
FrontmanFin
Icon for Altostratus rankAltostratus
Apr 12, 2024

iRule for Logging a HTTP::header

Hello, we have a VS that services multiple FQDNs to one VS and then chooses the pool using an LTM policy that checks the incoming http host from the client and then associates to the pool.

 

I have a working irule that looks like:

 

when HTTP_REQUEST_RELEASE {
    foreach x [HTTP::header names] {
        log local0. "$x: [HTTP::header $x]"
    }
}

the problem is, this returns all the headers for every HTTP_request for this VS, for ALL The FQDNs, when i really only need it for one specific one.

I know in the header there is a 

Host field for the fqdn.

 

is there a way to modify my irule above to only log the header for the HTTP::headers that contain the url lets say webserverA.com?

 

Note: I tried to do the logging in the LTM policy for when it chooses the WebserverA pool, but while it says it accepts TCL, I don't know what to put in there.

 

  • I believe the following is what you're looking for.

    when HTTP_REQUEST priority 500 {
    
        if { [string tolower [HTTP::host]] == "webservera.com" }{
            log local0. "[HTTP:host]"
        }
    
    }

     

  • I believe the following is what you're looking for.

    when HTTP_REQUEST priority 500 {
    
        if { [string tolower [HTTP::host]] == "webservera.com" }{
            log local0. "[HTTP:host]"
        }
    
    }