Forum Discussion
iRule that redirects to Sorry Pool when pool is down
When all of the webservers in a pool are down, I want my users to be directed to the "SorryPage" server pool that will display a maintenance/down page. I've been reading through the forums and I think the best way to do this is via iRules due to the persistent profile issue that can occur when using priorities. I've basically copied other iRules from past posts.
So, I would like to include 1 of these 2 iRules to my webserver VIP. I would like to know which is a better iRule. Does one of these rules run faster or perhaps more efficiently that the other? Thanks for your help.
RULE 1:
when CLIENT_ACCEPTED {
Check if the VS default pool has no active members
if {[active_members [LB::server pool]] == 0}{
pool sorry_pool
}
}
RULE 2:
when CLIENT_ACCEPTED {
Save the name of the VS default pool
set default_pool [LB::server pool]
}
when HTTP_REQUEST {
Check if the VS default pool has any active members
if {[active_members $default_pool]}{
pool $default_pool
} else {
pool sorry_pool
}
}
- nitassEmployeefor maintenance page, i think we should use HTTP_REQUEST event and HTTP::uri command in addition to pool command since we may have to change url when sending to maintenance pool. and i do not think we need to save default pool name in CLIENT_ACCEPTED event.
[root@ve10:Active] config b virtual bar list virtual bar { snat automap pool foo destination 172.28.19.79:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve10:Active] config b pool foo list pool foo { monitor all fake members 200.200.200.101:80 {} } [root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { if {[active_members [LB::server pool]] < 1} { HTTP::uri / pool sorrypool } } } [root@ve10:Active] config b pool sorrypool list pool sorrypool { members 200.200.200.102:80 {} } default pool is down [root@ve10:Active] config b pool foo|grep -i pool POOL foo LB METHOD round robin MIN/CUR ACTIVE MEMBERS 0/0 +-> POOL MEMBER foo/200.200.200.101:80 inactive,down client accesses virtual server and is sent to sorrypool instead [root@ve10:Active] config ssldump -Aed -nni 0.0 port 80 and not host 200.200.200.10 New TCP connection 1: 172.28.19.251(44474) <-> 172.28.19.79(80) 1345898352.5804 (0.0009) C>S --------------------------------------------------------------- HEAD /something HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Host: 172.28.19.79 Accept: */* --------------------------------------------------------------- New TCP connection 2: 200.200.200.80(44474) <-> 200.200.200.102(80) 1345898352.5875 (0.0070) C>S --------------------------------------------------------------- HEAD / HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Host: 172.28.19.79 Accept: */* ---------------------------------------------------------------
- jasona_40790NimbostratusSo, my iRule is as follows:
- hooleylistCirrostratusHi Jason,
when CLIENT_ACCEPTED { set sorry_debug 1 set default_pool [LB::server pool] } when HTTP_REQUEST { if {[active_members $default_pool] < 1} { if {$sorry_debug}{log local0. "[IP::client_addr]:[TCP::client_port]: Using sorry pool for [HTTP::uri]"} HTTP::uri / pool sorrypool } else { if {$sorry_debug}{log local0. "[IP::client_addr]:[TCP::client_port]: Using pool $default_pool for [HTTP::uri]"} pool $default_pool } } when SERVER_CONNECTED { if {$sorry_debug}{log local0. "[IP::client_addr]:[TCP::client_port]: Connected to [LB::server] - [IP::server_addr]:[TCP::server_port]"} }
- keenon_49862NimbostratusI have tried these i'm using 11.3 and have no luck on making them work in my setup
- nitassEmployeeI have tried these i'm using 11.3 and have no luck on making them work in my setupwhat is not working indeed?
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