Forum Discussion

Senthil_7991's avatar
Senthil_7991
Icon for Nimbostratus rankNimbostratus
Mar 20, 2017
Solved

Add new iRule with same VIP

The current VIP (Port 443) already running with below iRule but we also want to add one more iRule.

 

Please help us to know how to merge with single iRule or chances to add new iRule?

 

Current iRule ( Redirect to Pool member of Port 8443)

when HTTP_REQUEST { if { (([string tolower [HTTP::host]] equals "xxxxxx") and ([string tolower [HTTP::uri]] starts_with "/servicecenter")) } { pool XXXXXX_8443 } }

 

Below New iRule ( We planning to redirect to Pool member of Port 8444)

when HTTP_REQUEST {

 

if { (([string tolower [HTTP::host]] equals "xxxxxxxx") and ([string tolower [HTTP::uri]] starts_with "/users")) } { pool xxxxxxx_8444}

 

}

 

  • I believe host name is not same in both iRule. Find the consolidated irule based on condition.

     when HTTP_REQUEST 
            {
           if { (([string tolower [HTTP::host]] equals "xxxxxx") and ([string tolower [HTTP::uri]] starts_with "/servicecenter")) } 
                { pool XXXXXX_8443 }
        elseif { (([string tolower [HTTP::host]] equals "xxxxxxxx") and ([string tolower [HTTP::uri]] starts_with "/users")) } 
                { pool xxxxxxx_8444 }
            }
    

    Use switch option if the host name is common in both irule.

6 Replies

  • I believe host name is not same in both iRule. Find the consolidated irule based on condition.

     when HTTP_REQUEST 
            {
           if { (([string tolower [HTTP::host]] equals "xxxxxx") and ([string tolower [HTTP::uri]] starts_with "/servicecenter")) } 
                { pool XXXXXX_8443 }
        elseif { (([string tolower [HTTP::host]] equals "xxxxxxxx") and ([string tolower [HTTP::uri]] starts_with "/users")) } 
                { pool xxxxxxx_8444 }
            }
    

    Use switch option if the host name is common in both irule.

    • Senthil_7991's avatar
      Senthil_7991
      Icon for Nimbostratus rankNimbostratus

      Thanks

       

      In this case host is same "abc.com", May I know how to us switch option?.

       

      when HTTP_REQUEST { if { (([string tolower [HTTP::host]] equals "abc.com") and ([string tolower [HTTP::uri]] starts_with "/servicecenter")) } { pool XXXXXX_8443 } elseif { (([string tolower [HTTP::host]] equals "abc.com") and ([string tolower [HTTP::uri]] starts_with "/users")) } { pool xxxxxxx_8444 } }

       

    • Samir_Jha_52506's avatar
      Samir_Jha_52506
      Icon for Noctilucent rankNoctilucent

      write irule like this.

          when HTTP_REQUEST {
      
          if { ([string tolower [HTTP::host]] equals "abc.com") }
          {
          set uri [string tolower [HTTP::uri]]
          switch -glob $uri {
        "/servicecenter*" { pool XXXXXX_8443 }
        "/users/" { pool xxxxxxx_8444 } }
      

      } }

    • Samir_Jha_52506's avatar
      Samir_Jha_52506
      Icon for Noctilucent rankNoctilucent

      write irule like this.

          when HTTP_REQUEST {
      
          if { ([string tolower [HTTP::host]] equals "abc.com") }
          {
          set uri [string tolower [HTTP::uri]]
          switch -glob $uri {
        "/servicecenter*" { pool XXXXXX_8443 }
        "/users/" { pool xxxxxxx_8444 } }
      

      } }