Forum Discussion

GavinW_29074's avatar
GavinW_29074
Icon for Nimbostratus rankNimbostratus
Nov 22, 2011

ProxyPass V10 iRule issues...

Hi there,

 

 

I'm trying to set-up the ProxyPass v10 iRule from here (http://devcentral.f5.com/wiki/iRules.ProxyPassV10.ashx), and I'm hitting a few issues with Firefox...

 

 

It's probably worth noting that I've made a couple of tweaks to the rule to fit with how we intend to use it...

 

Top section of the rule looks like this now:

 

when RULE_INIT {
    Enable to debug ProxyPass translations via log messages in /var/log/ltm
    (2 = verbose, 1 = essential, 0 = none)
   set static::ProxyPassDebug 02

    Enable to rewrite page content (try a setting of 1 first)
    (2 = attempt to rewrite host/path and just /path, 1 = attempt to rewrite host/path)
   set static::RewriteResponsePayload 0
}

when CLIENT_ACCEPTED {
    Get the default pool name.  This is used later to explicitly select 
    the default pool for requests which don't have a pool specified in 
    the class.
   set default_pool [LB::server pool]

   if { $static::ProxyPassDebug > 1 } {
      log local0. "[virtual name]: [IP::client_addr]:[TCP::client_port] -> [IP::local_addr]:[TCP::local_port]"[IP::local_addr]:[TCP::local_port] DefaultPool: $default_pool"
   }
}

when HTTP_REQUEST {
    "bypass" tracks whether or not we made any changes inbound so we
    can skip changes on the outbound traffic for greater efficiency.
   set bypass 1

    The name of the Data Group (aka class) we are going to use
   set vname [getfield [virtual name] / 4]
   set cname [substr $vname 0 .]
   set clname "ProxyPass[virtual name]""ProxyPass_$cname"

    Initialize other local variables used in this rule
   set orig_uri "[HTTP::uri]"
   set orig_host "[HTTP::host]"
   set log_prefix "VS=[virtual name], Host=$orig_host, URI=$orig_uri"
   set clientside ""
   set serverside ""
   set newpool ""
   set ppass ""

   if {! [class exists $clname]} {
      log local0. "$log_prefix: Data Group $clname not found."
      pool $default_pool
      return
   } else {
  log local0. "$log_prefix: Data Group $clname found."   
      set ppass [class match -element "$orig_host$orig_uri" starts_with $clname]
      if {$ppass eq ""} {
          Did not find with hostname, look for just path
         set ppass [class match -element "$orig_uri" starts_with $clname]
      }
      if {$ppass eq ""} {
          No entries found
         if { $static::ProxyPassDebug > 0 } {
            log local0. "$log_prefix: No rule found"  
         }

   Get default redirect value. 
  set rurl [class match -value $cname equals Root_Redirect]
  if { $static::ProxyPassDebug > 0 } {
log local0. "$log_prefix: redirect found. Redirecting to $rurl"
  }

 HTTP::redirect "https://[HTTP::host]$rurl" 
         pool $default_pool
         return
      }
   }
Basically, I've changed the name format of the datagroup that it's looking for, and added a 'Default redirect' which is used to catch either the root directory or an invalid application URL. 
This code works fine in IE, however I'm consistently getting the following error in FF:Corrupted Content Error
The page you are trying to view cannot be shown because an error in the data transmission was detected.
Any ideas where this issue could come from? 
  • Scratch that... Wasn't rendering right on my phone...

    Try changing the line as follows:

     set vname "[string range [virtual name] [expr {[string last / [virtual name]]+1} ] end]"

    Cheers

    G