Forum Discussion

NewTOF501_15047's avatar
NewTOF501_15047
Icon for Nimbostratus rankNimbostratus
Apr 10, 2014

irule which check if uri contains services

I need a irule which check if uri contains services like http://domain.name.com/services" or "oservices" then send traffic to service_pool or oservice_pool but before that it should change uri to /wps/portal instead of /services or /oservices

 

35 Replies

  • You should assign something like the following iRule to your virtual server:

    when HTTP_REQUEST {
        if { [HTTP::uri] contains "services" } {
            HTTP::redirect "/wps/portal"
            pool SERVICE_POOL
        }
        elseif { [HTTP::uri] contains "oservices" } {
            HTTP::redirect "/wps/portal"
            pool OSERVICE_POOL
        }
    }
    
    • NewTOF501_15047's avatar
      NewTOF501_15047
      Icon for Nimbostratus rankNimbostratus
      Thanks. I tried but it is sending traffic to default pool not to member of service_pool
    • a_pavlov_114144's avatar
      a_pavlov_114144
      Icon for Cirrus rankCirrus
      You can add some logging to your irule to make sure that conditions in if statement work fine. And then look in /var/log/ltm for your messages. Like this: when HTTP_REQUEST { log local0. "URI = [HTTP::uri]" if { [HTTP::uri] contains "services" } { HTTP::redirect "/wps/portal" pool SERVICE_POOL log local0. "SERVICE POOL" } elseif { [HTTP::uri] contains "oservices" } { HTTP::redirect "/wps/portal" pool OSERVICE_POOL log local0. "OSERVICE_POOL" } }
  • Hi I am new to iRule, i have this irule redirecting http trafic to WWW_Maximo_pool:

     

    when HTTP_REQUEST { if { [HTTP::uri] contains "MAXPROD" } { pool WWW_Maximo_pool } else { HTTP::redirect https://[HTTP::host][HTTP::uri] } }

     

    i want it to do the same redirect for HTTPS trafic, so i did the follwoing modification:

     

    when HTTP_REQUEST or HTTPS_REQUEST { if { [HTTP::uri] contains "MAXPROD" } or { [HTTPS::uri] contains "MAXPROD" } { pool WWW_Maximo_pool } else { HTTP::redirect https://[HTTP::host][HTTP::uri] } }

     

    but that gave me a compilation error. Any help is highly appreciated.

     

    Thanks. Eddy.

     

  • Jibin_43310's avatar
    Jibin_43310
    Historic F5 Account

    Change to the following:

    when HTTP_REQUEST {
        if {{ [HTTP::uri] contains "MAXPROD" } || { [HTTPS::uri] contains "MAXPROD" }} {
            pool WWW_Maximo_pool
        } else {
            HTTP::redirect https://[HTTP::host][HTTP::uri] 
        }
    }
    

    Same to HTTPS_REQUEST