Forum Discussion
Irule maintanance page with ifile
Hi there,
I'd like to create a maintanance page irule which i can attach to a VIP if necessary. We've an existing custom prebuild maintanance page with images and css file. I've uploaded all the files (images/ccs and html) with the import ifile list option. After that I created this Irule to begin with:
when HTTP_REQUEST { HTTP::respond 200 content get ifile "error.html"
}
This doesn't show the page but when I paste the whole html content in the irule I don't get to see the images either. So I don't know to proceed.
13 Replies
- What_Lies_Bene1
Cirrostratus
Have you uploaded the images as iFiles too? Also, you'll need to respond based on what is requested if you're going to use them.
See here for an example of this: https://devcentral.f5.com/wiki/irules.Automatic_maintenance_page___Sorry_page_with_images.ashx
- nitass
Employee
when HTTP_REQUEST { HTTP::respond 200 content get ifile "error.html" }
you don't forget square bracket around the ifile command, do you?
- Matt_Dierick
Employee
This mine, working on my BIGIP. If you want to use ifile, you need to get ifile name. Below, I launch 404 ifile (404.html page) and I request each picture in this html page with ifile.
when HTTP_REQUEST { used for 404 error page. Send each image png file to 404 HTML page. switch -glob [string tolower [HTTP::uri]] { "*.png" { Remove slash and png on /imagexxxx.png and call iFile imagexxxxx HTTP::respond 200 content [ifile get [getfield [string range [HTTP::uri] 1 end] "." 1]] } default {} } } when HTTP_RESPONSE { if { [HTTP::status] == 404 } { log local0. "Error 404" ifile 404 is the HTML page with a reference to photoxxxx.png HTTP::respond 200 content [ifile get 404] } - heskez_36146
Nimbostratus
Thanks for all comments. I've tried with the brackets before. Also without success.. Apparently I'm doing it wrong. Ifile list within Irules is empty! I select the html file and named it and now I can see the content. Many thanks, I'm going to try to display the images as well..
- heskez_36146
Nimbostratus
Hmm, this isn't getting me further. I ended up with something like this: when HTTP_REQUEST { "error.html" {HTTP::respond 200 content [ifile get error.html] "Content-Type" "text/html"} "index.css" {HTTP::respond 200 content [ifile get index.css] "Content-Type" "text/css"} "logo.gif" {HTTP::respond 200 content [ifile get logo.gif] "Content-Type" "image/gif"} } }
But this doesn't show me the maintanance page. Am I on the correct path?
- nitass
Employee
[ifile get error.html]
is error.html ifile object (local traffic > irules > ifile list)?
- heskez_36146
Nimbostratus
Yes, it is in the ifile list now.
- nitass
Employee
But this doesn't show me the maintanance page. Am I on the correct path?
there is switch command in the irule similar to Matthieu's example, isn't it?
- heskez_36146
Nimbostratus
The difference is that we'd like to schedule the maintanance. So we don't need the
if {[active_members [LB::server pool]] <1}Statement
We just apply the irule on the VIP.
Why is this not working?
when HTTP_REQUEST { "error.html" {HTTP::respond 200 content [ifile get error.html] "Content-Type" "text/html"} "index.css" {HTTP::respond 200 content [ifile get index.css] "Content-Type" "text/css"} "logo.gif" {HTTP::respond 200 content [ifile get logo.gif] "Content-Type" "image/gif"} } } - Kevin_Stewart
Employee
You still need 1) the switch/if context to evaluate the URI, and 2) a default condition to display the html page:
when HTTP_REQUEST { switch [HTTP::uri] { "/index.css" { HTTP::respond 200 content [ifile get index.css] "Content-Type" "text/css" } "/logo.gif" { HTTP::respond 200 content [ifile get logo.gif] "Content-Type" "image/gif" } default { HTTP::respond 200 content [ifile get error.html] "Content-Type" "text/html" } } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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