Forum Discussion
nathe
Oct 21, 2011Cirrocumulus
Redirect Based on Content
Hello all. Hope you can help. Not new to f5 but new to writing my own iRules.
Scenario: I want to redirect a user to an error page if a certain line of text is returned in the html bod...
nitass
Oct 21, 2011Employee
is response encoded or does it span multiple packet?
[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_RESPONSE {
set collect_length 2048
if {[HTTP::header Content-Length] eq ""}{
set collect_length $collect_length
} elseif {[HTTP::header Content-Length] == 0}{
unset collect_length
} elseif {[HTTP::header Content-Length] > $collect_length}{
set collect_length $collect_length
} else {
set collect_length [HTTP::header Content-Length]
}
if {[info exists collect_length]}{
HTTP::collect $collect_length
}
}
when HTTP_RESPONSE_DATA {
if { [HTTP::payload] contains "Microsoft OLE DB Provider for SQL Server error"}{
log local0. "found OLE DB Error in response"
HTTP::redirect http://www.domain.com/error.asp
}
}
}
[root@iris:Active] config curl -i http://10.10.70.110/foo.html
HTTP/1.1 200 OK
Date: Fri, 21 Oct 2011 06:27:51 GMT
Server: Apache/2.0.59 (rPath)
Last-Modified: Fri, 21 Oct 2011 06:24:47 GMT
ETag: "66a9-80-213129c0"
Accept-Ranges: bytes
Content-Length: 128
Vary: Accept-Encoding
Set-Cookie: testcookie=helloworld
Content-Type: text/html; charset=UTF-8
WELCOME!!!!
This's 10.10.70.110.
Microsoft OLE DB Provider for SQL Server error
[root@iris:Active] config curl -i http://172.28.17.33/foo.html
HTTP/1.0 302 Found
Location: http://www.domain.com/error.asp
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
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