Forum Discussion
Maintanance Irule two issues
Hi there,
We've build a cool maintanance Irule (With your help much appreciated)
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"
return 0
}
}
}
This seems to work fine but there are several issues though. The first issue, and that's why I've put the "return 0" in, is the combinantion with multiple Irules. Allthough I've put the return 0 in, I still see (In the logging) the next Irule is being hit and therefore the maintanance doesn't show. So I have to remove all irules from the VS and just put the maintanance Irule on Why?
The second issue is for example I put the maintanance on a VS which listens to www.x.com So when I type www.x.com the maintanance page shows up. But for example when I type in www.x.com/something , the maintance text shows up but the images aren't shown. I would like to see the images when I type www.x.com/something. Is there a way to optimize this Irule to achieve this?
21 Replies
- heskez_36146
Nimbostratus
Thanks Nitass, I've put an "event disable" in front of every section and now I can clearly see the maintanance page comes up with the images shown, it works great! So the first issue is resolved.
Concerning the second issue, most people have some favorite in their browser, so when they click there's something like www.x.com/application/eninge the images of the maintanance page doesn't show up. When I type www.x.com/application the images do show up! So, we're almost there. So I'd like in the Irule something like redirect /application/engine to root path www.x.com. That would probably solve it. Is this the correct syntax?
set RequestedPath [string tolower [HTTP::path]] switch $RequestedPath { "/" { HTTP::respond 200 content [ifile get error.html] "Content-Type" "text/html" } } - heskez_36146
Nimbostratus
Or what I actually want to do is
when HTTP_REQUEST { if { [HTTP:uri] starts_with "/" } "Call the script Else "Do something else" Is that possible? - nitass
Employee
So I'd like in the Irule something like redirect /application/engine to root path www.x.com.
you can do but shouldn't it be easier to use switch glob-style matching similar to this?
when HTTP_REQUEST { switch -glob [HTTP::path] { "*/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" } } } - heskez_36146
Nimbostratus
@Nitass: Thanks, I'll give it a try!
- heskez_36146
Nimbostratus
I tried it but the problem is when an address is type like: http://www.x.com/something/somemoreinput The images aren't shown. Also when typed http://www.x.com/something/ (notice the / at the end)
So the best thing to do I guess is call another script part or another irule from this irule with
when HTTP_REQUEST { if { [HTTP:uri] starts_with "/" }"Call the script"
I don't see how i'm going to get this running with the global switch parameter.
- nitass
Employee
I tried it but the problem is when an address is type like: http://www.x.com/something/somemoreinput The images aren't shown. Also when typed http://www.x.com/something/ (notice the / at the end)
can you post the irule here?
- heskez_36146
Nimbostratus
Sure.
when HTTP_REQUEST { switch -glob [HTTP::path] { "/index.css" { HTTP::respond 200 content [ifile get index.css] "Content-Type" "text/css" event disable } "/logo.gif" { HTTP::respond 200 content [ifile get logo.gif] "Content-Type" "image/gif" event disable } "/corners2-grid1-half.png" { HTTP::respond 200 content [ifile get corners2-grid1-half.png] "Content-Type" "image/gif" event disable } "/body2-grid1-half.gif" { HTTP::respond 200 content [ifile get body2-grid1-half.gif] "Content-Type" "image/gif" event disable } "/canvas-bottom.png" { HTTP::respond 200 content [ifile get canvas-bottom.png] "Content-Type" "image/gif" event disable } "/default.jpg" { HTTP::respond 200 content [ifile get default.jpg] "Content-Type" "image/gif" event disable } default { HTTP::respond 200 content [ifile get error.html] "Content-Type" "text/html" event disable } } } - nitass
Employee
did you forget to add asterisk (*) in switch pattern?
- heskez_36146
Nimbostratus
Where should i put the asterisk?
- heskez_36146
Nimbostratus
Never mind, I forgot :)
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