I have an iRule that redirects traffic to another pool by uri. I want to be able to mark the site offline with a placeholder if the default pool is unavailable. I have a seperate pool for my placeholder server. It works fine for the default pool offline but not if I try teh redirected pool. Any suggestions?
Basically when the pool is unavailable if I go to qa.website.com the site maintenance page comes up. If I go to qa.website.com/us/blah blah blah I get a page not found. Where as if the pool is available the qa.website.com/us/blah blah blah page loads fine. My end goal is to have the maintenance page appear for both pools whenever the default pool is unavailable.
So I took Kevin and nitass’s advice. I created a new rule: when RULE_INIT {
set static::DEBUG 1
}
when HTTP_REQUEST {
if { [active_members INF-HC-HTTP] < 1 } {
if { $static::DEBUG } { log local0. "Primary pool offline" }
HTTP::uri /
pool QA-PH
} elseif { [class match [string tolower [HTTP::uri]] starts_with QA-HC-URI] } {
pool INF-HC-HTTPDNN
} else {
pool INF-HC-HTTP
}
}}
with a string data group called QA-HC-URI and everything works like a charm except for one piece. When the maintenance page comes up it loads the text but the CSS and the images are missing. When I wireshark it, it says everything is fine and the logs on the server say it’s being delivered but they don’t show up. If I host file to the server directly it comes up perfectly. I’m clueless. Thanks.
So I ran a wireshark after setting the rule and I understand why it’s not getting the file… GET /us/resource/images/logo.gif shouldn’t work, it’s not being redirected to the QA-PH pool. /images/logo.gif is the right path but /us/resource/ is the original source. So I have to figure out how to get it to GET /images/logo.gif without the /us/resource/
GET /us/resource/images/logo.gif shouldn’t work, it’s not being redirected to the QA-PH pool. /images/logo.gif is the right path but /us/resource/ is the original source.
why is the path not correct? isn’t it (maintenance html page) generated by GET / to pool QA-PH?
anyway, if you want to remove /us/resource/ in request for css and image file, you can use string map command similar to this.
e.g.
when HTTP_REQUEST {
if { [active_members INF-HC-HTTP] < 1 } {
if { $static::DEBUG } { log local0. "Primary pool offline" }
switch -glob [string tolower [HTTP::path]] {
"*css" -
"*jpg" -
"*gif" -
"*png" {
HTTP::uri [string map {/us/resource/ /} [HTTP::uri]]
}
default {
HTTP::uri /
}
}
pool QA-PH
} elseif { [class match [string tolower [HTTP::uri]] starts_with QA-HC-URI] } {
pool INF-HC-HTTPDNN
} else {
pool INF-HC-HTTP
}
}
this is what i understand… when requesting http://qa.hcareers.com/us/resouce but INF-HC-HTTP pool is down, request would be changed to http://qa.hcareers.com/ due to HTTP::uri / command and sent to pool QA-PH. pool QA-PH will respond with maintenance html page. then client will send another request for object (e.g. css, image) which is inside the html page.
nope. The INF-HC-HTTP pool is currently offline. When I open a web page and enter http://qa.hcareers.com/us/resource/default.aspx I get the maintenance page with the text and no css or gif’s. When I look at my wireshark capture the GET is GET /us/resource/styles.css and GET /us/resource/images/logo.gif.
Also, It works in IE but Chrome and Firefox bring up error pages. Chrome is it’s usually Opps and Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
I can’t get this figured and it can’t be this hard. All I want is an iRule that:
A) go to main page: qa.hcareers.com and if pool is unavailable go to another pool that has a site unavailable web page
B) go to login page: qa.hcareers.com/access/… and if pool is unavailable go to another pool that has a site unavailable web page (same pool and web page as A).
C) go to resource page: qa.hcareers.com/resource/… and if pool is unavailable go to another pool that has a site unavailable web page (same pool and web page as A).
If I use: if { [active_members INF-HC-HTTP] < 1 }
{ if { $static::DEBUG } { log local0. “Primary pool offline” }
HTTP::uri /
pool QA-PH
}
A) works fine. B) brings up the text but not the css or gif’s, HTTPFox and wire shark report the correct URL of qa.hcareers.com/images/logo.gif and 200 OK. C) same as B.
I am sooooooo close. Read through nitass reply and changed my rule around some. If I test with: when RULE_INIT
{ set static::DEBUG 1 }
when HTTP_REQUEST {
if { [active_members INF-HC-HTTP] < 1 }
{ switch -glob [string tolower [HTTP::path]]
{
"*.gif" -
"*.css" {
HTTP::uri [string range [HTTP::uri] [string last / [HTTP::uri]] end]
}
default {
HTTP::uri /
}
}
pool QA-PH
} }
everything works like a charm on all parts of my web site. Main, resource and access all come up with images and CSS and it’s all right. Problem is if I try to add:
when RULE_INIT
{ set static::DEBUG 1 }
when HTTP_REQUEST {
if { [active_members INF-HC-HTTP] < 1 }
{ switch -glob [string tolower [HTTP::path]]
{
"*.gif" -
"*.css" {
HTTP::uri [string range [HTTP::uri] [string last / [HTTP::uri]] end]
}
default {
HTTP::uri /
}
}
pool QA-PH
} } elseif
{ [class match [string tolower [HTTP::uri]] starts_with QA-HC-URI] } {
pool INF-HC-HTTPDNN
}
else { pool INF-HC-HTTP } }
I get 2 errors - Line 4 [wrong of args] and line 23 [command not valid in current scope]. I’ve dug through the code and I don’t see any missing open/close brackets and the logic og the if/elseif’s makes sense to me but I’ve got to be missing something.