Forum Discussion
Shah_83712
Nimbostratus
May 17, 2010Covert a 4.x irule to 10.x irule
Below is the some 4.x irule i need converted to 10.x can some one help please? Also please understand I am brand new to F5 so please post as detailed as possible.
Number 1 Rule:
if (http_uri starts_with "/privacy.asp") { if (http_uri == "/privacy.asp?lang=en") { redirect to "http://uk.mysurvey.com/index.cfm?" + "action=Main.lobbyGeneral&myContent=PRIVACYPOLICY" } else { if (http_uri starts_with "/privacy.asp?lang=") { redirect to "http://" + findstr(http_uri, "lang=", 5, 2) + ".mysurvey.com/index.cfm?" + "action=Main.lobbyGeneral&myContent=PRIVACYPOLICY" } else { redirect to "http://uk.mysurvey.com/index.cfm?" + "action=Main.lobbyGeneral&myContent=PRIVACYPOLICY" } } } else { use pool MAPSYS2.2 }
Number 2 Rule:
if (client_addr == 10.1.0.0 netmask 255.255.255.0) { use pool centurion1 } else { redirect to "http://maintenance.tns-global.com" }
Number 3 Rule:
if (http_uri contains "maint_mode.htm") { redirect to "http://206.104.153.202/maint_mode.htm" } else { if (client_addr == 10.1.0.0 netmask 255.255.0.0 and client_addr != 10.1.14.252 netmask 255.255.255.255) { if (server_addr == 206.104.153.110 netmask 255.255.255.255) { use pool NEW_CLUSTER_HTTP } else { use pool fun_http } } else { if (http_uri contains "msas.cfm") { if (http_uri matches_regex "[sS][uU][rR][vV][eE][yY][sS]") { redirect to "http://206.104.153.202/msas1.htm" } else if (http_uri matches_regex "[Aa][Ll][Ee][Rr][Tt]") { redirect to "http://206.104.153.202/msas2.htm" } else { redirect to "http://206.104.153.202/msas3.htm" } } else { redirect to "http://206.104.153.202/maint.htm" } } }
4 Replies
- hoolio
Cirrostratus
Hi Shah, Here are untested 10.x equivalents: Number 1 Rule:
v10:if (http_uri starts_with "/privacy.asp") { if (http_uri == "/privacy.asp?lang=en") { redirect to "http:// uk.mysurvey.com/index.cfm?" + "action=Main.lobbyGeneral&myContent=PRIVACYPOLICY" } else { if (http_uri starts_with "/privacy.asp?lang=") { redirect to "http://" + findstr(http_uri, "lang=", 5, 2) + ".mysurvey.com/index.cfm?" + "action=Main.lobbyGeneral&myContent=PRIVACYPOLICY" } else { redirect to "http:// uk.mysurvey.com/index.cfm?" + "action=Main.lobbyGeneral&myContent=PRIVACYPOLICY" } } } else { use pool MAPSYS2.2 }
Number 2 Rule:when HTTP_REQUEST { if {[string tolower [HTTP::uri]] starts_with "/privacy.asp"}{ if {[HTTP::uri] eq "/privacy.asp?lang=en"}{ HTTP::redirect "http:// uk.mysurvey.com/index.cfm?action=Main.lobbyGeneral&myContent=PRIVACYPOLICY" } else { if {[HTTP::uri] starts_with "/privacy.asp?lang="}{ HTTP::redirect "http://[findstr [HTTP::uri] "lang=" 5 2].mysurvey.com/index.cfm?action=Main.lobbyGeneral&myContent=PRIVACYPOLICY" } else { HTTP::redirect "http:// uk.mysurvey.com/index.cfm?action=Main.lobbyGeneral&myContent=PRIVACYPOLICY" } } } else { use pool MAPSYS2.2 } }
v10:if (client_addr == 10.1.0.0 netmask 255.255.255.0) { use pool centurion1 } else { redirect to "http:// maintenance.tns-global.com" }
Number 3 Rule:when CLIENT_ACCEPTED { if {[IP::addr [IP::client_addr]/24 equals 10.1.0.0]}{ pool centurion1 set redirect 0 } else { set redirect 1 } } when HTTP_REQUEST { if {$redirect==1}{ HTTP::redirect "http:// maintenance.tns-global.com" } }
v10:if ([HTTP::uri] contains "maint_mode.htm") { redirect to "http:// 206.104.153.202/maint_mode.htm" } else { if (client_addr == 10.1.0.0 netmask 255.255.0.0 and client_addr != 10.1.14.252 netmask 255.255.255.255) { if (server_addr == 206.104.153.110 netmask 255.255.255.255) { use pool NEW_CLUSTER_HTTP } else { use pool fun_http } } else { if ([HTTP::uri] contains "msas.cfm") { if ([HTTP::uri] matches_regex "[sS][uU][rR][vV][eE][yY][sS]") { redirect to "http:// 206.104.153.202/msas1.htm" } else if ([HTTP::uri] matches_regex "[Aa][Ll][Ee][Rr][Tt]") { redirect to "http:// 206.104.153.202/msas2.htm" } else { redirect to "http:// 206.104.153.202/msas3.htm" } } else { redirect to "http:// 206.104.153.202/maint.htm" } } }
Aaronwhen HTTP_REQUEST { if {[HTTP::path] ends_with "maint_mode.htm"}{ redirect to "http:// 206.104.153.202/maint_mode.htm" } else { if {[IP::addr [IP::client_addr]/16 equals 10.1.0.0] && ![IP::addr [IP::client_addr] equals 10.1.14.252]}{ if {[IP::addr [IP::server_addr] equals 206.104.153.110]}{ pool NEW_CLUSTER_HTTP } else { pool fun_http } } else { if {[HTTP::path] ends_with "msas.cfm"} { if {[string tolower [HTTP::uri]] contains "surveys"}{ HTTP::redirect "http:// 206.104.153.202/msas1.htm" } elseif {[string tolower [HTTP::uri]] contains "alert"}{ HTTP::redirect "http:// 206.104.153.202/msas2.htm" } else { HTTP::redirect "http:// 206.104.153.202/msas3.htm" } } else { HTTP::redirect "http:// 206.104.153.202/maint.htm" } } } } - hoolio
Cirrostratus
To work around the munging of URLs in the iRule code, I've inserted spaces between http:// and the rest of the URL. So make sure to remove those spaces when you test the iRule.
Aaron - Shah_83712
Nimbostratus
Thanks for your help, I am going to give it a try today.
- Shah_83712
Nimbostratus
All of the rules were accepted, still waiting on our team to do the testing.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
