Forum Discussion
active members check on multiple pools
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?
iRule: when HTTP_REQUEST { set DEBUG 0 if { $DEBUG } { log local0. "Request: [HTTP::uri]" } if {[active_members QA-HC-HTTP] < 1} { pool QA-PH return } if { $DEBUG } { log local0. "Request: [HTTP::uri]" } switch -glob [string tolower [HTTP::uri]] { "/portals/" - "/js/" - "/controls/" - "/uk/" - "/us/" - "/ca/" - "/admin/controlpanel/" - "/webresource" - "/scriptresource" - "/resources/" - "/providers/" - "/linkclick" - "/documentation/" - "/desktopmodule/" - "/config/" - "/components/" - "/bin/" - "/app_themes/" - "/app_globalResources/" - "/app_data/" - "/app_code/" - "/app_browser/" - "/dnnaadmin/" - "/contactus/" - "/resourcecenter/i" - "/resourcecenter/r" - "/resourcecenter/j" - "/resourcecenter/e" { if { $DEBUG }{log local0. "Sending request to QA-HC-HTTPDNN"} if {[active_members QA-HC-HTTP] < 1} { pool QA-PH return } pool QA-HC-HTTPDNN } default { pool QA-HC-HTTP} } }
21 Replies
- ryan_rockwell_1
Nimbostratus
The path isn't correct because /us/resource is part of the INF-HC-HTTP pool not part of the QA-PH pool. I would assume when I'm making a request to http://qa.hcareers.com/us/resouce and the INF-HC-HTTP pool is down that the request would be http://qa.hcareers.com/images/logo.gif not http://qa.hcareers.com/us/resource/images/logo.gif.
- nitass
Employee
I would assume when I'm making a request to http://qa.hcareers.com/us/resouce and the INF-HC-HTTP pool is down
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.
isn't this how it works?
- ryan_rockwell_1
Nimbostratus
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.
- nitass
Employee
oh yes, you are correct. sorry, i misthought.
would you mind trying this?
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" { do nothing } default { HTTP::redirect "http://[HTTP::host]" } } pool QA-PH } elseif { [class match [string tolower [HTTP::uri]] starts_with QA-HC-URI] } { pool INF-HC-HTTPDNN } else { pool INF-HC-HTTP } } - ryan_rockwell_1
Nimbostratus
It works but I don't want to rewrite the URL back to the main page.
- ryan_rockwell_1
Nimbostratus
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.
- nitass
Employee
It works but I don't want to rewrite the URL back to the main page.
in that case, you have to correct path for css and image before sending to pool QA-PH. :)
- ryan_rockwell_1
Nimbostratus
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.
- ryan_rockwell_1
Nimbostratus
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.
- nitass
Employee
is it something like this?
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 } }
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