Forum Discussion
iRule: Failure to activate payload
Hi, folks,
I'm getting a result I don't understand on a very simple iRule. It works in this version:
when HTTP_REQUEST { if {some_stuff} {
drop
log local0.warn "Warning"
}
But this does not display the HTML:
when HTTP_REQUEST { if {some_stuff} {
HTTP::respond 200 content { <html>Some HTML</html> }
log local0.warn "Warning"
}
And neither does this:
when HTTP_REQUEST { if {some_stuff} {
HTTP::respond 200 content { [ifile get _our_ifile] "Content-Type" "text/html;charset=utf-8" }
log local0.warn "Warning"
}
I've verified that the HTML is valid. What am I missing?
Thanks,
John A
- Jeffrey_GranierEmployee
Hi John,
Not sure of the error your getting but essentially something like this should work:
when HTTP_REQUEST {
# Log the intercepted request (optional, for debugging)
log local0. "HTTP Request intercepted: [HTTP::method] [HTTP::uri]"# Respond with custom HTML content
HTTP::respond 200 content {
<!DOCTYPE html>
<html>
<head>
<title>Custom Response</title>
<style>
body { font-family: Arial, sans-serif; background-color: #f0f0f0; text-align: center; padding: 50px; }
h1 { color: #333; }
p { font-size: 18px; color: #666; }
</style>
</head>
<body>
<h1>Welcome to F5 BIG-IP!</h1>
<p>This response was generated directly by an F5 iRule.</p>
<p>Have a great day!</p>
</body>
</html>
}
}- John_AdamsAltocumulus
Hi, Jeffery,
That's very much like what I have, and yet, it does not work. I'm not getting an error, and the logging works. It just fails to deliver the page.
Thanks,
John A
- John_AdamsAltocumulus
You know what fixed me up? Changing that first line to: when HTTP_REQUEST priority 1000 {
- Jeffrey_GranierEmployee
Interesting, did you already have other HTTP_Request event handlers elsewhere? or were there additional irules applied to the VS... Either way if you use the same event handlers across different irules applied to a VS or within the same irule you should apply priority to direct what event and action should be processed first 😀
- John_AdamsAltocumulus
There were additional iRules applied, mostly with explicit priorities set.
Recent Discussions
Related Content
* 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