Forum Discussion
nitass
Oct 19, 2011Employee
HTTP::cookie is not valid in CLIENT_ACCEPTED.
HTTP::cookie wiki
http://devcentral.f5.com/wiki/iRules.HTTP__cookie.ashx
[root@iris:Active] config b virtual bar list
virtual bar {
snat automap
pool foo
destination 172.28.17.33:http
ip protocol tcp
rules myrule
profiles {
http {}
tcp {}
}
}
[root@iris:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
set flag 0
if {[HTTP::cookie exists "testcookie"]} {
set flag 1
set http_request_time [clock clicks -milliseconds]
set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]"
}
}
when HTTP_RESPONSE {
if {$flag} {
log local0. "$LogString (response) - pool info: [LB::server] - status: [HTTP::status] (request/response delta: [expr [clock clicks -milliseconds] - $http_request_time]ms)"
}
}
}
GET / is not shown in log since testcookie has not been presented at the first request (it is set by pool member in the first response). log is written in /var/log/ltm file. if you want to write to another file, you can customize syslog-ng config.
[root@iris:Active] config tail -f /var/log/ltm
Oct 19 17:59:17 local/tmm info tmm[4601]: Rule myrule : Client 192.168.206.102:63807 -> 172.28.17.33/dog.gif (response) - pool info: foo 10.10.70.110 80 - status: 200 (request/response delta: 1ms)
Oct 19 17:59:17 local/tmm info tmm[4601]: Rule myrule : Client 192.168.206.102:63807 -> 172.28.17.33/favicon.ico (response) - pool info: foo 10.10.70.110 80 - status: 404 (request/response delta: 2ms)
Oct 19 17:59:17 local/tmm info tmm[4601]: Rule myrule : Client 192.168.206.102:63807 -> 172.28.17.33/favicon.ico (response) - pool info: foo 10.10.70.110 80 - status: 404 (request/response delta: 2ms)