Forum Discussion

3 Replies

  • Josiah_39459's avatar
    Josiah_39459
    Historic F5 Account

    Check out the example irules here:

    https://devcentral.f5.com/wiki/iRules.pool.ashx

    especially this one seems exactly like what you want to do

    --

    when HTTP_REQUEST {
       if { [HTTP::uri] ends_with ".gif" } {
          if { [LB::status pool my_Pool member 10.1.2.200 80] eq "down" } {
             log "Server $ip $port down!"
             pool fallback_Pool
          } else {
             pool my_Pool member 10.1.2.200 80
          }
       }
    }
    

    --

    • Anuj_Chaudhary_'s avatar
      Anuj_Chaudhary_
      Icon for Nimbostratus rankNimbostratus
      My backend servers are 172.23.100.11 and 172.23.100.12 Uatservices.goindigo.in should go. To both servers..rest URLs should go nly 172.19.100.11..how will be the irule ? Can we include all poinintg URLs word in one irule ???
  • With that many URI's you may want to use a switch statement. The base URL with no URI would end up being the last matching statement.

    https://devcentral.f5.com/questions/host-with-multiple-uri

    when HTTP_REQUEST { 
        switch -glob [string tolower [HTTP::path]] {
            "*/uri-1/*" -
            "*/uri-2/*" {
                HTTP::redirect "https://www.mysite.com[HTTP::uri]"
                or use:
                 pool my_pool-1
                return
                }
            "*/uri-3/*" {
                pool my_pool-2
            return
            }
            }
            default {
                if {[string tolower [HTTP::uri]] equals "/"} {
                    HTTP::redirect "https://www.myothersite.com[HTTP::uri]"  
                    return
                }
            }
    }
    

    HTH,