Forum Discussion

Mark_Porter_979's avatar
Mark_Porter_979
Icon for Nimbostratus rankNimbostratus
Oct 12, 2005

Percent character encoding and irules

I have an irule that looks at the request_uri to determine which pool to use:

 

 

if (http_uri matches_regex "/[Vv][Ee][Nn][Dd][Oo][Rr]_[Mm][Gg][Tt]") {

 

use pool lm-pmweb-2k3

 

}

 

else {

 

use pool lm-web-prod

 

}

 

 

The problem is that the 2k3 IIS devices are building a redirect to add the trailing / onto the directory name, but encoding the _ character.

 

 

If I request http://site.d.com/vendor_mgt, IIS responds with a 302, and sends me to http://site.d.com/vendor%5Fmgt/ . The problem is that by replacing the _ with a %5F, the irule doesn't match any longer, and I go to the wrong pool.

 

 

Is there a way to make the irule decode the %5F so that it will match?

 

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    I'd suggest making a change like:

    
    if (http_uri matches_regex "/[Vv][Ee][Nn][Dd][Oo][Rr].*[Mm][Gg][Tt]") {
    use pool lm-pmweb-2k3
    }
    else {
    use pool lm-web-prod
    }

    This would match vendor and mgt, regardless of what seperated them.

    You could, of course, make a more strict version to only match a certain number of characters if you so chose.

    -Colin
  • Martin_Machacek's avatar
    Martin_Machacek
    Historic F5 Account
    Mark,

    if you are running BIG-IP 4.6.x or newer, you can use following rule:

    
    rule match_vendor_mgt {
      if(tolower(decode_uri(http_uri)) == "/vendor_mgt")
          use pool lm-pmweb-2k3
      } else {
          use pool lm-web-prod
      }
    }

    The decode_uri function translates %XX escape following rules defined in RFC2396. The tolower function translates ASCII uppercase characters to their lowercase equivalents. The above rule should be more efficient than regex matching.

    BIG-IP versions older than 4.6 do not support the tolower function.