Forum Discussion
Ed_27995
Nimbostratus
Jun 18, 2008iRule seems to block page request
Hi All,
I have created the following iRule-
when HTTP_REQUEST {
if {[findstr [HTTP::uri] "webctid=" 8 2] == "83"}
{HTTP::redirect "http://distance-ed.bcc.ctc.edu/bbmaint.asp"}
elseif {[findstr[HTTP::uri] "webctid=" 8 2] == "95"}
{HTTP::redirect "http://distance-ed.bcc.ctc.edu/bbmaint.asp"}
}
What I am trying to do is redirect student login requests, identified by the "83" or "95" in the above rule, to a maintenance page.
When I go into the iRule manager and make the iRule active, the login page does not display when I go to the site.
Do I need an else block to tell the BigIP that if the preceding conditions are not matched to forward the request to an app node normally? If so, how is that done?
My thinking when creating the iRule was that if the string was encountered in an HTTP request, the redirect would be triggered, but if the string was not encountered the web requests would processed normally.
Do I have the wrong event in HTTP_REQUEST?
Thanks in advance for your help!
Ed
- Nicolas_Menant
Employee
Hi,when HTTP_REQUEST { log local0. "uri is [HTTP::uri]" set val [findstr [HTTP::uri] "webctid=" 8 2] log local0. "val is $val" if {$val == "83"} { log local0. "val matched 83" HTTP::redirect "http://distance-ed.bcc.ctc.edu/bbmaint.asp" } elseif {$val == "95"} { log local0. "val matched 95" HTTP::redirect "http://distance-ed.bcc.ctc.edu/bbmaint.asp" } }
- Ed_27995
Nimbostratus
Hi nmenant, - Can you post the exact URI you are trying to match to? That way we have some way of testing it.
- Found at least one of your issues. You don't have a space between the second "findstr" and "[HTTP::uri]". The TCL processor is trying to run the command "findstr[HTTP::uri]" which throws a runtime exception that you should see in the /var/log/ltm file.
when HTTP_REQUEST { switch [findstr [HTTP::uri] "webctid=" 8 2] { "83" - "95" { log local0. "Found match, redirecting to maintenance page..." HTTP::redirect "http://distance-ed.bcc.ctc.edu/bbmaint.asp" } } }
- Ed_27995
Nimbostratus
Here's what I'm seeing from a Wireshark capture: - Now I'm glad I asked for the URI. Per your trace, the value of "webctid=" is not in the URI at all but in the HTTP payload data. So, from the looks of your trace, you would want to do a HTTP::collect in the HTTP_REQUEST event and then process the HTTP::payload value in the HTTP_REQUEST_DATA event. Search for "HTTP_REQUEST_DATA" in the site search and you'll find lots of examples.
- Ed_27995
Nimbostratus
Thanks Joe!
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