Forum Discussion

phipse's avatar
phipse
Icon for Altostratus rankAltostratus
Mar 09, 2017

iRule not hitting default pool?

Hi Guys, I have created an iRule to select a pool based on the URL the user goes to.

 

testurl.com goes to pool_group1

 

testurl.com/diagnostics/* goes to pool_group2

 

The testurl.com/diagnostics/* works fine, however the testurl.com doesn't seem to work at all when the iRule is applied to the Virtual Server. Is there something I'm missing?

 

 

14 Replies

  • it could be because you are searching on http::path, but im not 100% about this. But i have made a suggestion, that takes a slightly different approach:

                when HTTP_REQUEST {
                  if { [string tolower [HTTP::uri]] starts_with "diagnostics"} {
                    pool pool_group2
                    persist source_adr 255.255.255.255 1800 
                      }
                 else { pool pool_group1 
                  }
                }
    
    • Kai_Wilke's avatar
      Kai_Wilke
      Icon for MVP rankMVP

      Hai Kai, 😉

      [HTTP::uri]
      or
      [HTTP::path]
      are in this specific scenario almost interchangeable. And adding a
      [string tolower]
      command is always a good idea if endusers are involved... 😉

      Cheers, Kai

    • Kai_M__48813's avatar
      Kai_M__48813
      Icon for Cirrus rankCirrus

      yeah..was a bit unsure about that...so i just used http::uri out of old habit, and probably a lack of coffee:D

       

      string tolower should almost be mandatory, if you ask me..has saved me countless hours of troubleshooting, because of end users using capital letters when typing in the url..

       

    • phipse's avatar
      phipse
      Icon for Altostratus rankAltostratus

      Something seems to be wrong with the syntax?

       

      Please see error below

       

      /CCRegressionTEST/irule_CCdiagnosticsimages_redirect:4: error: ["invalid argument source_adr; expected syntax spec: (add|carp|cookie|delete|dest_addr|hash|lookup|msrdp|none|simple|sip|source_addr|ssl|sticky|uie|universal) "][persist source_adr 255.255.255.255 1800 ]

       

  • Hi phipse,

    you iRule looks absolutely valid^^

    For testing purposes you may try to the iRules below and then take a look to your logfiles...

    Test1: Forwarding every request to pool_group1

    when HTTP_REQUEST {
        log local0.debug "iRule executed..."
        pool pool_group1
    }
    

    Test2: Same as your iRule with added logging

    when HTTP_REQUEST {
        log local0.debug "Debug: iRule executed..."
        switch -glob -- [HTTP::uri] {
            "/diagnostics/*" {
                log local0.debug "Debug: Hit the /diagnostics path."
                persist source_addr 255.255.255.255 1800
                pool pool_group2
            }
            default {
                log local0.debug "Debug: Hit the default path"
                pool pool_group1
            }
        }
    }
    

    Cheers, Kai

  • add the following to the irule to see what are we getting back from the server

    when HTTP_RESPONSE {

    log local0.debug "server Status respose [HTTP::status] if you get 301 or 302 is a redirect, 4XX are authentication and page not found, 200 good respose from the server"
    log local0.debug "Http::header [HTTP::header names ] "
    log local0.debug "header location [HTTP::header Location]"
    

    }

    • phipse's avatar
      phipse
      Icon for Altostratus rankAltostratus

      I've added this iRule and receive the following in the logs.

       

       

    • phipse's avatar
      phipse
      Icon for Altostratus rankAltostratus

      Guys,

       

      Just to let you know this resolved the issue.

       

       

      When I used this, it broke :-/

       

       

      Everything seems to be OK now.

       

      Thank you EVERYONE for your help!

       

  • add the following to the irule to see what are we getting back from the server

    when HTTP_RESPONSE {

    log local0.debug "server Status respose [HTTP::status] if you get 301 or 302 is a redirect, 4XX are authentication and page not found, 200 good respose from the server"
    log local0.debug "Http::header [HTTP::header names ] "
    log local0.debug "header location [HTTP::header Location]"
    

    }

    • phipse's avatar
      phipse
      Icon for Altostratus rankAltostratus

      I've added this iRule and receive the following in the logs.

       

       

    • phipse's avatar
      phipse
      Icon for Altostratus rankAltostratus

      Guys,

       

      Just to let you know this resolved the issue.

       

       

      When I used this, it broke :-/

       

       

      Everything seems to be OK now.

       

      Thank you EVERYONE for your help!