Forum Discussion
Tim_W_72292
Nimbostratus
Oct 24, 2007Irule with Multiple HTTP checks
Hi All,
I am trying to write a rule that will do multiple check within the HTTP headers, is this possible? Here is what I was thinking:
if {[HTTP::host] equals and [HTTP::status] equals "400" and [HTTP::uri] starts_with "/url"} {
log local0, "log of issue"}
}
Will this work as I think it will or are there constraints on the HTTP headers checks?
Cheers
Tim
- hoolio
Cirrostratus
You can get the response status in the HTTP_RESPONSE event, but you have to get the Host and URI from a clientside event. This means you have to save the URI for every request to that server. Here's an example:when HTTP_REQUEST { use IP::addr to compare Host header value with the IP we're looking for if {[IP::addr [HTTP::header value Host] equals 1.1.1.1]}{ for a match, save the URI to log if the response is a 400 set uri [HTTP::uri] } } when HTTP_RESPONSE { check if HTTP response status is a 400 if {[HTTP::status] == 400}{ Log the client IP address and the URI log local0. "[IP::client_addr] -> $uri generated 400 response" } }
- Tim_W_72292
Nimbostratus
Aaron, - hoolio
Cirrostratus
HTTP::header value Host would return what the client enters in the address bar between the protocol and the URI. For http://test.example.com:80/path/to/file.ext?parameter=value, the Host would be test.example.com:80. If a user accessed https://1.1.1.1/somefile.txt, the Host would be 1.1.1.1. - Tim_W_72292
Nimbostratus
Aaron, - hoolio
Cirrostratus
So do you want to log which server the 400 response was received from--regardless of which one it was? If so, this example will log the client and server IP's and the requested URI for all 400 responses. If that's not what you're after, can you clarify again?when HTTP_REQUEST { save the URI to log if the response is a 400 set uri [HTTP::uri] } when HTTP_RESPONSE { check if HTTP response status is a 400 if {[HTTP::status] == 400}{ Log the client and server IP addresses and the URI log local0. "[IP::client_addr] -> [IP::server_addr] for $uri generated 400 response" } }
- Tim_W_72292
Nimbostratus
Hey Aaron, - hoolio
Cirrostratus
If we say that www.example.com is the host and /index.html is the URI, do you want to log only for some host header values or only for some URIs? Do you have a few hosts or URIs or a lot? - Tim_W_72292
Nimbostratus
That was a bad example from me, just one URI /example/login.jsp - Tim_W_72292
Nimbostratus
One other thing that would be good, I have checked the docs I have but cannot find it, Is it possible to mark a node as down with an irule? So for the above rule, if it notice the node1 was failing then it only sent to node2 and marked node1 as inactive? - hoolio
Cirrostratus
Good to hear the rule looks good. You could mark a node down using LB::down (Click here).
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects