Forum Discussion

pw-itc's avatar
pw-itc
Icon for Nimbostratus rankNimbostratus
Mar 13, 2019

Rewrite, iRule

Hi,

 

we have the following situation.

 

name.abc.com/ -> ProdServerFQDN/application

 

name.abc.com/dev -> DevServerFQDN/application

 

For casting / -> /application and /dev -> /application we are using a rewrite-profile. Now we want to use an iRule for choosing the destination pool. That's where the order, how the F5 processes rewrite-profiles and iRules, comes into play. Because of the rewrite our iRule has no information about the original uri and can not work properly.

 

Is there any way to get around this problem? Does the F5 keep the original uri somewhere (variable) when rewriting it or can we somehow adjust the processing order of our rewrite-profiles and iRules?

 

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    I'm thinking if you need to stack functionality you may want to move the rewrite to the iRule as well. Otherwise it becomes rather murky.

    Keep in mind that F5's strategy has always been to internalize certain features if a lot of customers relied on iRules for those. The redirect and rewrite profiles are good examples of those. In addition, using iRules gives you full control over and access to the request values.

    Unfortunately, profiles tend to limit the option, at times to the detriment of standards like RFC 7230 et al. For instance, the redirect profile is still limited (or at least used to be for years) to 302. Of course, to a degree this applies to the

    HTTP::redirect
    in iRules as well, but at least one could use
    HTTP::respond
    instead. But I digress...

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    A few observations after a quick glance:

    1. Instead of
      starts_with
      I would recommend matching (i.e.
      eq
      ) the actual host. This avoids issues if another instance is added at some point.
    2. The FQDN you're using is invalid. Although I assume it's a placeholder, make sure you drop the slash (
      /
      ).
    3. The path you're matching (
      /dev
      ) may be too limited. Keep in mind that other valid matches may include
      /dev/
      ,
      /dev/index.html
      , et cetera. This would be a good candidate for
      starts_with
      .
    4. I would group the header manipulations. In other words, move the pool selection to the bottom.