Forum Discussion

eirikn's avatar
eirikn
Icon for Nimbostratus rankNimbostratus
Mar 30, 2015

Stop processing iRule(s) if condition is met.

Hi,

Im hosting a site with two virtual servers http and https.

My http virtual server is just a set of rules that redirects to the https virtual server.

One visitor of my site needs to access some parts in http, and i have made a iRule that distinguish the traffic and sends it directly to the pool. No redirection. :

when HTTP_REQUEST {
if { ([string tolower [HTTP::uri]] contains "/globalassets/global/") and [IP::remote_addr] contains "XXX.XXX" } {
                pool dummy_web_pool
                log 10.X.X.X local0.info "http Client Connected, IP: [IP::client_addr]"
                return
}

I can from my syslog see that the iRule hits, but i still get a 301 redirect response. Even though this iRule is top priority, it seems like it continues to read my other lower priority https redirection irules.

How can bypass my other iRules if the condition is met?

9 Replies

  • Use the

    event disable
    command after calling your conditional actions, to disable further processing of HTTP_REQUEST event. Use the
    event disable all
    command to stop further processing all iRule events.

    Good luck 😃

    • eirikn's avatar
      eirikn
      Icon for Nimbostratus rankNimbostratus
      Thanks for quick response! event disable did the trick!
    • Joe_Pruitt's avatar
      Joe_Pruitt
      Yes, return will just return from control from the current code block (event), it won't return from all iRules.
    • AmalW_114471's avatar
      AmalW_114471
      Icon for Nimbostratus rankNimbostratus

      Thanks a lot @Hannes Rapp That did the trick for me too.. We were struggling with adding maintenacne page redirection irules where we have x-forwarded-header inserts. This is just what we were looking for..

       

      Thanks again!!!

       

  • Use the

    event disable
    command after calling your conditional actions, to disable further processing of HTTP_REQUEST event. Use the
    event disable all
    command to stop further processing all iRule events.

    Good luck 😃

    • eirikn's avatar
      eirikn
      Icon for Nimbostratus rankNimbostratus
      Thanks for quick response! event disable did the trick!
    • Joe_Pruitt's avatar
      Joe_Pruitt
      Yes, return will just return from control from the current code block (event), it won't return from all iRules.
    • AmalW_114471's avatar
      AmalW_114471
      Icon for Nimbostratus rankNimbostratus

      Thanks a lot @Hannes Rapp That did the trick for me too.. We were struggling with adding maintenacne page redirection irules where we have x-forwarded-header inserts. This is just what we were looking for..

       

      Thanks again!!!

       

  • Hi,

     

    Will if elseif pair not solve this as well, so when if condition (special client) is true pool action is performed, if it's not true redirection to https is performed? Just iRule newbie question.

     

    Piotr