Forum Discussion
John45_41805
Nov 10, 2011Nimbostratus
Using if HTTP::header value Content-Type contains "text"
When I choose something as my content type...lets call it ..johnsname
do i have to define johnsname in the F5 or assuming I know my header info it will be detected by the F5 automatically and read it and perform the filter i apply..
basically I want to confirm if i had the following code:
if {[HTTP::header value johnsname] not "default"}
Then I could assume the F5 would automatically read my header look for the assigned value of johnsname and as long as it wasn't default it would perform the actions i listed below that string ?
I'm brand new to iRules and want to make sure I have a clear understanding.
- nitassEmployeee.g.
[root@ve1023:Active] config b virtual bar list virtual bar { snat automap pool foo destination 172.28.65.152:http ip protocol tcp rules myrule profiles { http {} tcp {} } } [root@ve1023:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { if {[HTTP::header value johnsname] equals "default"} { log local0. "it is default" } else { log local0. "it is not default" } } } [root@ve1023:Active] config curl -I http://172.28.65.152/ -H "johnsname: default" HTTP/1.1 200 OK Date: Thu, 10 Nov 2011 16:31:32 GMT Server: Apache/2.2.3 (CentOS) Last-Modified: Tue, 08 Nov 2011 12:54:37 GMT ETag: "4183c9-30-ac7cfd40" Accept-Ranges: bytes Content-Length: 48 Connection: close Content-Type: text/html; charset=UTF-8 [root@ve1023:Active] config curl -I http://172.28.65.152/ -H "johnsname: test" HTTP/1.1 200 OK Date: Thu, 10 Nov 2011 16:31:39 GMT Server: Apache/2.2.3 (CentOS) Last-Modified: Tue, 08 Nov 2011 12:54:37 GMT ETag: "4183c9-30-ac7cfd40" Accept-Ranges: bytes Content-Length: 48 Connection: close Content-Type: text/html; charset=UTF-8 [root@ve1023:Active] config tail /var/log/ltm Nov 10 08:31:18 local/tmm info tmm[4766]: Rule myrule : it is default Nov 10 08:31:24 local/tmm info tmm[4766]: Rule myrule : it is not default
- hooleylistCirrostratusOr you could use not or ! to negate the match:
when HTTP_REQUEST { if { not ([HTTP::header value johnsname] equals "default")} { log local0. "it is not default" } }
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