Forum Discussion

Shah_83712's avatar
Shah_83712
Icon for Nimbostratus rankNimbostratus
May 17, 2010

Covert 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

  • Hi Shah, Here are untested 10.x equivalents: 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
    }
    
    v10:
    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
    }
    }
    
    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" }
    
    v10:
    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"
    }
    }
    
    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"
    }
    }
    }
    
    v10:
    when 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"
    }
    }
    }
    }
    
    Aaron
  • 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
  • All of the rules were accepted, still waiting on our team to do the testing.