Forum Discussion

BaltoStar_12467's avatar
Aug 02, 2013

sample irule for redirect / rewrite

BIG-IP VE (Virtual Edition) v10.2.4 ( build 577.0 )

 

Could someone please provide or point me to an irule that performs redirects / rewrites , including the match class and associated data-file.

 

Thanks.

 

 

 

16 Replies

  • Good question, and difficult to give a definitive answer. Here are a few options though:

     

     

    1. The timing command in iRules: https://devcentral.f5.com/wiki/iRules.timing.ashx

     

    2. I'm a big fan of both Apache Jmeter and LoadUI (both free) for local stress testing.

     

    3. A cool document on performance testing methodology: https://devcentral.f5.com/downloads/f5/creating-performance-test-methodology.pdf

     

    4. Performance testing with HTTPWatch: https://devcentral.f5.com/wiki/advdesignconfig.Programmatic-Performance-Testing-With-HttpWatch.ashx

     

    5. There are a few testing frameworks out there. I can't recommend any because I haven't used them.

     

     

    I'd also ask, are these redirects for a single application, or many?

     

  • Scenario is a single monolithic site being broken-up into micro-sites - but not in one fell swoop, so all sites must co-exist for a period of time.

     

     

    Micro-sites are deployed with natural-language urls that each are mapping to an old-style url that is handled by the monolithic site server.

     

     

    So the need for redirects is motivated by SEO.

     

     

    In addition to redirects, also have need perform invisible rewrites of the natural language URLs to the the old-style URLs ( handled by the monolithic site ).

     

     

    QUESTION : how exactly should I perform the rewrite ? I've seen rewrite iRules written like this :

     

     

    when HTTP_REQUEST {

     

    if { [class match [string tolower [HTTP::uri]] starts_with rewrites_datagroup] } {

     

    HTTP::uri "http://[class match -value [string tolower [HTTP::uri]] starts_with rewrites_datagroup]"

     

    }

     

    }

     

     

    But what I find strange is that the apparently there's no need to specify the destination pool ... ?

     

     

    So how exactly does the request find its way to the pool ?
  • The pool in your example is explicitly declared in the virtual server configuration. The HTTP::uri command simply rewrites the incoming URI on the way to the server.
  • Ok so if virtual server has an assigned default pool , then just set uri. But if no default pool assigned , must also direct to a pool , correct ?

     

  • I successfully tested my redirect/rewrite irule against data-groups with external data-files of 100 , 1K , 10K records ....

     

    However, when I changed my data-group to point to a 100K record file , it crashed f5 !

     

    Here's what happened : I had an existing data-group pointed to a 10K record file , which I re-pointed to a 100K record file. I clicked "Update" and the file upload process began but ultimately hung. Next the browser admin page crashed with the "lost connection" message. Attempts to re-invoke the browser admin failed similarly.

     

    Rebooting Linux didn't help much. The browser admin page was very slow to load and ultimately displayed a banner message "General database error retrieving information". I was able to navigate the menus but when I clicked the data-group the browser admin hung and crashed just as before.

     

    Next , I modified bigip.conf , changing the data-group to point to the 10K record file. Reboot, but not luck.

     

    Next, I modified bigip.conf , removing all references to external data-files ( deleted data-groups , deleted irule , modified vip to not use irule ). Reboot, but no luck.

     

    Possibly, BIG-IP stores startup config instructions and/or sequences in its db which is now in an unstable state -- potentially telling f5 on startup to attempt to load the 100K record file ? Or how could my actions have put f5 in an unstable state ?

     

    How to recover my f5 instance ? Or is it totally trashed ?

     

    My understanding is that v10.2.4 should support load/cache of a 100K record data-file -- is this correct ?

     

    Thanks for any help.