<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>iRules</title>
        <link>http://devcentral.f5.com/weblogs/cwalker/category/29.aspx</link>
        <description>iRules tricks, tips and interesting tidbits.</description>
        <language>en-US</language>
        <copyright>Colin Walker</copyright>
        <managingEditor>c.walker@f5.com</managingEditor>
        <generator>Subtext Version 1.9.5.176</generator>
        <item>
            <title>Mashup: SDBP Boston, Caching and iRules - oh my!</title>
            <link>http://devcentral.f5.com/weblogs/cwalker/archive/2008/11/06/mashup-sdbp-boston-caching-and-irules---oh-my.aspx</link>
            <description>&lt;p&gt;Whew! It's been a whirlwind of a couple weeks.  Between the annual F5 sales conference, where Joe and I presented to a bunch of awesome F5 techies, followed immediately by a very cool trip to present with the famed &lt;a href="http://devcentral.f5.com/weblogs/macvittie/" target="_blank"&gt;Lori&lt;/a&gt; at the &lt;a href="http://www.sdbestpractices.com/" target="_blank"&gt;SD Best Practices&lt;/a&gt; event in Boston, I've barely had time to do laundry, sleep in my own bed and feed my puppy. It's good to be back, but what cool stuff I got to see/hear/talk about!&lt;/p&gt;  &lt;p&gt;The Software Development Best Practices (SDBP) conference was hawesome. It's great to be around so many people &lt;img style="margin: 10px 0px 10px 20px" height="57" src="https://www.cmpevents.com/SDe8/images/sdbpstatichdr2.gif" width="338" align="right" /&gt;that get "it" and share the same geeked out passion for development, computing and cool technology that I do. While there I not only got to have several awesome conversations while hanging out in the F5 booth on site, but also got to give a fun Technical Session with &lt;a href="http://devcentral.f5.com/weblogs/macvittie/archive/2008/10/24/hope-to-see-you-at-sd-best-practices.aspx" target="_blank"&gt;Lori (which she mentioned before we left)&lt;/a&gt; which I think went over pretty well. It was F5's first time at this conference but hopefully not our last, as I think the audience is a great one to get in front of when talking about the amazing things that our gear can do to help extend the application. Whether it's via standard LTM features, iControl or iRules, it's almost always a killer story.&lt;/p&gt;  &lt;p&gt;One of the many stories we told when talking about things we can do for the application was the &lt;a href="http://blog.linkedin.com/2008/06/23/web-scalability-practices-bumper-sticker-on-rails/ " target="_blank"&gt;Joyent / Bumpersticker&lt;/a&gt; application story. For those of you that haven't heard it yet, I highly recommend checking it out. We've got some pretty detailed info in the interview that Joe and I did with Jason, their CTO, which &lt;a href="http://devcentral.f5.com/weblogs/interviews/archive/2008/07/23/scaling-in-the-cloud-with-joyents-jason-hoffman.aspx" target="_blank"&gt;you can check out&lt;/a&gt; here. The short version is that Joyent scaled Bumpersticker app from Linkedin to over a billion pageviews a month, running on Ruby on Rails, and they couldn't have done it without F5 and iRules. How cool is that?!?&lt;/p&gt;  &lt;p&gt;They did this via a combination of intelligent caching and a smattering of iRules that garnered an 80% reduction in application load (80%!!11), allowing them to get way more bang for their processing buck. This, along with some other cool conversations I had regarding caching and some of the things we can do with it, led me to put together a &lt;a href="http://devcentral.f5.com/Default.aspx?tabid=63&amp;amp;articleType=ArticleView&amp;amp;articleId=283" target="_blank"&gt;tech tip that begins to delve into the world of caching and iRules&lt;/a&gt; on the LTM. More detail will follow I'm sure, but this starts the journey at least.&lt;/p&gt;  &lt;p&gt;That's all for now, more later as always.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:32d0f80c-d724-453a-b85a-8ba80e64389a" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SDBP" rel="tag"&gt;SDBP&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Caching" rel="tag"&gt;Caching&lt;/a&gt;,&lt;a href="http://technorati.com/tags/iRules" rel="tag"&gt;iRules&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Joyent" rel="tag"&gt;Joyent&lt;/a&gt;,&lt;a href="http://technorati.com/tags/LinkedIn" rel="tag"&gt;LinkedIn&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Facebook" rel="tag"&gt;Facebook&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Ruby%20on%20Rails" rel="tag"&gt;Ruby on Rails&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Colin%20Walker" rel="tag"&gt;Colin Walker&lt;/a&gt;&lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Listening to: Alter Bridge - One Day Remains - One Day Remains&lt;/p&gt;  &lt;p&gt;#Colin&lt;/p&gt;&lt;div class='blogtags'&gt;&lt;/div&gt;&lt;img src="http://devcentral.f5.com/weblogs/cwalker/aggbug/3759.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Walker</dc:creator>
            <guid>http://devcentral.f5.com/weblogs/cwalker/archive/2008/11/06/mashup-sdbp-boston-caching-and-irules---oh-my.aspx</guid>
            <pubDate>Thu, 06 Nov 2008 17:28:20 GMT</pubDate>
            <wfw:comment>http://devcentral.f5.com/weblogs/cwalker/comments/3759.aspx</wfw:comment>
            <comments>http://devcentral.f5.com/weblogs/cwalker/archive/2008/11/06/mashup-sdbp-boston-caching-and-irules---oh-my.aspx#feedback</comments>
            <wfw:commentRss>http://devcentral.f5.com/weblogs/cwalker/comments/commentRss/3759.aspx</wfw:commentRss>
        </item>
        <item>
            <title>20 Lines or Less #15</title>
            <link>http://devcentral.f5.com/weblogs/cwalker/archive/2008/10/08/20-lines-or-less-15.aspx</link>
            <description>&lt;p&gt;&lt;em&gt;What could you do with your code in 20 Lines or Less?&lt;/em&gt; That's the question I ask every week, and every week I go looking to find cool new examples that show just how flexible and powerful iRules can be without getting in over your head.&lt;/p&gt;  &lt;p&gt;Finally back into the swing of the 20LoL, I'm happy to give you the 15th edition of this blog series. Today's offering is brought to you by me, F5, and the power of iRules (tm).  Okay, not really (tm), but it sounded cool.  I still find myself on a journey to seek out the coolest iRule tidbits that I can in hopes of bringing them to you and showing off just how much power you can pack into a minute amount of code in an iRule. This week's examples are nothing less than that, and hopefully you'll find at least one interesting, if not useful.&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Advanced URI Rewriting&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=28429&amp;amp;view=topic" href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=28429&amp;amp;view=topic"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=28429&amp;amp;view=topic&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In this example of rewriting a URI we go well past a simple directory change or query rewrite. This example goes a little further into the realm of the possible to show you how to rewrite a UID that is a portion of a complex URI. Thanks to hoolio and the other iRulers that contributed.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;when RULE_INIT {        &lt;br /&gt;   # Set a couple of test query strings         &lt;br /&gt;   #set source {a=123&amp;amp;k=456&amp;amp;uid=toto&amp;amp;h=789}         &lt;br /&gt;   #set source {uid=toto&amp;amp;a=123&amp;amp;k=456&amp;amp;h=789}         &lt;br /&gt;   set source {a=123&amp;amp;k=456&amp;amp;h=789&amp;amp;uid=toto}         &lt;br /&gt;   # Split the string into a list on the delimiter &amp;amp;         &lt;br /&gt;   log local0. "\[split \$source\ &amp;amp;]: [split $source &amp;amp;]"         &lt;br /&gt;   # Create a new query string         &lt;br /&gt;   set new_query_string ""         &lt;br /&gt;   # Loop through the list and create an array of parameters and values         &lt;br /&gt;   foreach param_value_pair [split $source &amp;amp;] {         &lt;br /&gt;      log local0. "\$param_value_pair: $param_value_pair"         &lt;br /&gt;      # If the current param value pair starts with uid=, then prepend it to the list of query string parameters         &lt;br /&gt;      if {$param_value_pair starts_with "uid="}{         &lt;br /&gt;         set new_query_string ${param_value_pair}${new_query_string}         &lt;br /&gt;      } else {         &lt;br /&gt;         set new_query_string ${new_query_string}&amp;amp;${param_value_pair}         &lt;br /&gt;      }         &lt;br /&gt;      log local0. "\$new_query_string: $new_query_string"         &lt;br /&gt;   }         &lt;br /&gt;   set new_query_string hxs=1&amp;amp;${new_query_string}         &lt;br /&gt;   log local0. "\$new_query_string: $new_query_string"         &lt;br /&gt;} &lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;HTTP to HTTPS redirect on 401&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=28235&amp;amp;view=topic" href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=28235&amp;amp;view=topic"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=28235&amp;amp;view=topic&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This iRule is built for a very specific deployment scenario which displays some ... interesting behaviors.  The requirement was to redirect back to the proper HTTPS URL for the site if authorization was required. This is done to ensure that things are secure where they need to be before allowing people to enter auth information.  I know it's not the most straight-forward way of doing things, but this particular deployment didn't have another workaround, so iRules came to the rescue.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="courier new"&gt;when HTTP_REQUEST {        &lt;br /&gt;   set host [HTTP::host]         &lt;br /&gt;   set uri [HTTP::uri]         &lt;br /&gt;}         &lt;br /&gt;when HTTP_RESPONSE {         &lt;br /&gt;   if {[HTTP::status] == 401]}{         &lt;br /&gt;      HTTP::redirect "&lt;/font&gt;&lt;a href="https://$host/"&gt;&lt;font face="courier new"&gt;https://$host/&lt;/font&gt;&lt;/a&gt;&lt;font face="courier new"&gt;$uri"        &lt;br /&gt;   }         &lt;br /&gt;} &lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Multi-Host HTTP Redirection with Switch&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=28200&amp;amp;view=topic" href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=28200&amp;amp;view=topic"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=28200&amp;amp;view=topic&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This example is a slightly trimmed version of the one provided (by hoolio, yet again) in the forum post. It shows some great ways to use a single switch to match many different domains or partial domains when doing a redirect based on a host. The individual pieces are all pretty straight-forward, but it's a great example of how to build a single, elegant logic flow rather than a bulkier if/else chain.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="courier new"&gt;when HTTP_REQUEST {        &lt;br /&gt;   log local0. "[IP::client_addr]:[TCP::client_port]: New HTTP request to [HTTP::host][HTTP::uri]"         &lt;br /&gt;   switch -glob [string tolower [HTTP::host]] {         &lt;br /&gt;      "*newlifepubs.com" {         &lt;br /&gt;         log local0. "[IP::client_addr]:[TCP::client_port]: Matched 1"         &lt;br /&gt;         HTTP::redirect "&lt;/font&gt;&lt;a href="http://www.example.com/nlp" ?="?"&gt;&lt;font face="courier new"&gt;http://www.example.com/nlp"&lt;/font&gt;&lt;/a&gt;       &lt;br /&gt;&lt;font face="courier new"&gt;      }        &lt;br /&gt;      "*mpd.example.org" {         &lt;br /&gt;         log local0. "[IP::client_addr]:[TCP::client_port]: Matched 2"         &lt;br /&gt;         HTTP::redirect "&lt;/font&gt;&lt;a href="http://staffweb.example.org/mpd/index.aspx" ?="?"&gt;&lt;font face="courier new"&gt;http://staffweb.example.org/mpd/index.aspx"&lt;/font&gt;&lt;/a&gt;       &lt;br /&gt;&lt;font face="courier new"&gt;      }        &lt;br /&gt;      "staff.example.org" {         &lt;br /&gt;         HTTP::redirect "&lt;/font&gt;&lt;a href="http://staffweb.example.org/" ?="?"&gt;&lt;font face="courier new"&gt;http://staffweb.example.org/"&lt;/font&gt;&lt;/a&gt;       &lt;br /&gt;&lt;font face="courier new"&gt;      }        &lt;br /&gt;      "*movementseverywhere.example.com" {         &lt;br /&gt;         HTTP::redirect "&lt;/font&gt;&lt;a href="http://www.example.org/" ?="?"&gt;&lt;font face="courier new"&gt;http://www.example.org/"&lt;/font&gt;&lt;/a&gt;       &lt;br /&gt;&lt;font face="courier new"&gt;      }        &lt;br /&gt;      default {         &lt;br /&gt;         log local0. "[IP::client_addr]:[TCP::client_port]: No match"         &lt;br /&gt;         discard         &lt;br /&gt;      }         &lt;br /&gt;   }         &lt;br /&gt;}&lt;/font&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;There's another 20LoL for your coding pleasure. Hopefully I've been able to fuel your desire to run out and whip up some awesome iRules yourself. Check back next week for more cool code!&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:2cd66c38-08bc-4ed4-9bbc-6b95a55059db" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/20%20Lines%20or%20Less" rel="tag"&gt;20 Lines or Less&lt;/a&gt;,&lt;a href="http://technorati.com/tags/HTTP%20Redirect" rel="tag"&gt;HTTP Redirect&lt;/a&gt;,&lt;a href="http://technorati.com/tags/401%20Auth%20Required" rel="tag"&gt;401 Auth Required&lt;/a&gt;,&lt;a href="http://technorati.com/tags/HTTPS%20redirect" rel="tag"&gt;HTTPS redirect&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Colin%20Walker" rel="tag"&gt;Colin Walker&lt;/a&gt;&lt;/div&gt;  &lt;p&gt;#Colin&lt;/p&gt;&lt;div class='blogtags'&gt;&lt;/div&gt;&lt;img src="http://devcentral.f5.com/weblogs/cwalker/aggbug/3698.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Walker</dc:creator>
            <guid>http://devcentral.f5.com/weblogs/cwalker/archive/2008/10/08/20-lines-or-less-15.aspx</guid>
            <pubDate>Thu, 09 Oct 2008 00:29:05 GMT</pubDate>
            <wfw:comment>http://devcentral.f5.com/weblogs/cwalker/comments/3698.aspx</wfw:comment>
            <comments>http://devcentral.f5.com/weblogs/cwalker/archive/2008/10/08/20-lines-or-less-15.aspx#feedback</comments>
            <wfw:commentRss>http://devcentral.f5.com/weblogs/cwalker/comments/commentRss/3698.aspx</wfw:commentRss>
        </item>
        <item>
            <title>20 Lines or Less # 14</title>
            <link>http://devcentral.f5.com/weblogs/cwalker/archive/2008/08/29/20-lines-or-less--14.aspx</link>
            <description>&lt;p&gt;&lt;em&gt;What could you do with your code in 20 Lines or Less?&lt;/em&gt; That's the question I ask every week, and every week I go looking to find cool new examples that show just how flexible and powerful iRules can be without getting in over your head.&lt;/p&gt;  &lt;p&gt;This week we've got three more fun examples of iRules goodness for you, thanks to the awesome community driving the forums and the CodeShare.  As always the goal is to show off some of the things that you can do with iRules in less than 21 lines of code. Let's dig in:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Distribute Email by Source IP&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://devcentral.f5.com/wiki/default.aspx/iRules/DistributeEmailBySourceIP.html" href="http://devcentral.f5.com/wiki/default.aspx/iRules/DistributeEmailBySourceIP.html"&gt;http://devcentral.f5.com/wiki/default.aspx/iRules/DistributeEmailBySourceIP.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;From the wiki comes this handy showcase of pool switching based on IP address. Putting this to good use by distributing info to different mail pools is an even cooler idea, which is just  what this iRule does.&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;when CLIENT_ACCEPTED {
   if { [IP::addr [IP::remote_addr] equals 10.2.0.0/255.255.0.0 ] }  {
     log local0. "Node IP address is: [IP::remote_addr] and sent to SMTP_clients_from_10.2"
     pool smtp_clients_from_10.2
   } else {
     log local0. "Node IP address is: [IP::remote_addr] and sent to SMTP_clients_from_elsewhere"
     pool SMTP_clients_from_elsewhere
   }&lt;/pre&gt;

  &lt;pre&gt;}&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;String Based HTTPS Redirect&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=26517&amp;amp;view=topic" href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=26517&amp;amp;view=topic"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=26517&amp;amp;view=topic&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yet another cool twist on the simple HTTP redirect iRules we've talked about before, this one uses a Location header in the response as well as a class of URIs to pick from. Even though it's a variation on a theme, it's cool to see the ways people are doing things, and remind us all that we have LOTS of options when it comes to iRuling. &lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre&gt; when HTTP_REQUEST {  &lt;br /&gt;    switch -glob [string tolower [HTTP::uri]] {  &lt;br /&gt;      "*alumni/giving/gift/" -  &lt;br /&gt;      "*alumni/giving/pledge/" -  &lt;br /&gt;      "*alumni/directory/search.aspx" -  &lt;br /&gt;      "*alumni/directory/update.aspx" {  &lt;br /&gt;      # don't do anything... &lt;br /&gt;      }  &lt;br /&gt;    default { &lt;br /&gt;       HTTP::respond 301 Location "http://[getfield [HTTP::host] : 1][HTTP::uri]"   &lt;br /&gt;      } &lt;br /&gt;    }  &lt;br /&gt;  }&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP Routing without HTTP Profile&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=26569&amp;amp;view=topic" href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=26569&amp;amp;view=topic"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=26569&amp;amp;view=topic&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This one is super cool (assuming it works..note that it's untested, but I like it anyway!). The issue here was that the user needed to inspect some HTTP information in a session without applying an HTTP profile to the Virtual Server. That means no HTTP:: commands. Oh no! Never fear, TCP::collect to the rescue!&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre&gt; when CLIENT_ACCEPTED { &lt;br /&gt;   TCP::collect &lt;br /&gt; } &lt;br /&gt; when CLIENT_DATA { &lt;br /&gt;   set idx [string first " HTTP/1." [TCP::payload]] &lt;br /&gt;   if { $idx &amp;lt; 0 } { &lt;br /&gt;     if { [TCP::payload length] &amp;gt; 2048 } { &lt;br /&gt;        log local0. "ERROR! Could not find HTTP request in 2K! dropping..." &lt;br /&gt;        reject &lt;br /&gt;     } else { &lt;br /&gt;       # Not enough data yet; collect more &lt;br /&gt;       TCP::collect &lt;br /&gt;     } &lt;br /&gt;     return &lt;br /&gt;   } &lt;br /&gt;   set request [string tolower [TCP::payload $idx]] &lt;br /&gt;   log local0. "Got request: $request" &lt;br /&gt;   if { $request contains " /XXXXX" } { &lt;br /&gt;     log local0. "Sending to Pool_XXXXX" &lt;br /&gt;     pool Pool_XXXXX &lt;br /&gt;   } else { &lt;br /&gt;     log local0. "Sending to Pool_WWWWW" &lt;br /&gt;     pool Pool_WWWWW &lt;br /&gt;   } &lt;br /&gt; } &lt;/pre&gt;
&lt;/blockquote&gt;

&lt;pre&gt;Hot off the presses, that's this week's 20LoL. Tune in again next week for even more iRule endeavors.&lt;/pre&gt;

&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f627a089-7aef-4f17-9809-5189e0553d40" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/20%20Lines%20or%20Less" rel="tag"&gt;20 Lines or Less&lt;/a&gt;,&lt;a href="http://technorati.com/tags/iRules" rel="tag"&gt;iRules&lt;/a&gt;,&lt;a href="http://technorati.com/tags/HTTP" rel="tag"&gt;HTTP&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SMTP" rel="tag"&gt;SMTP&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Colin%20Walker" rel="tag"&gt;Colin Walker&lt;/a&gt;&lt;/div&gt;

&lt;pre&gt;#Colin&lt;/pre&gt;&lt;div class='blogtags'&gt;&lt;/div&gt;&lt;img src="http://devcentral.f5.com/weblogs/cwalker/aggbug/3574.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Walker</dc:creator>
            <guid>http://devcentral.f5.com/weblogs/cwalker/archive/2008/08/29/20-lines-or-less--14.aspx</guid>
            <pubDate>Fri, 29 Aug 2008 19:22:20 GMT</pubDate>
            <wfw:comment>http://devcentral.f5.com/weblogs/cwalker/comments/3574.aspx</wfw:comment>
            <comments>http://devcentral.f5.com/weblogs/cwalker/archive/2008/08/29/20-lines-or-less--14.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://devcentral.f5.com/weblogs/cwalker/comments/commentRss/3574.aspx</wfw:commentRss>
        </item>
        <item>
            <title>20 Lines or Less #13</title>
            <link>http://devcentral.f5.com/weblogs/cwalker/archive/2008/08/22/20-lines-or-less-13.aspx</link>
            <description>&lt;p&gt;&lt;em&gt;What could you do with your code in 20 Lines or Less?&lt;/em&gt; That's the question I ask every week, and every week I go looking to find cool new examples that show just how flexible and powerful iRules can be without getting in over your head.&lt;/p&gt;
&lt;p&gt;After a couple of weeks out of the office, I'm back at it with your weekly dose of iRules goodness in under 20 lines. This week's 20LoL comes from the forums as well as the codeshare. We've got some great examples here, including one iRule that can be used to help augment an already existing LTM module and give it some extra functionality...cool stuff!&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Blocking Content with iRules&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=26722&amp;amp;view=topic" title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=26722&amp;amp;view=topic"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=26722&amp;amp;view=topic&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is a good example of a robust, logified way to block certain URI parameters from being allowed through to the back-end servers. Aaron's gone to the trouble to both document the code and the output heavily. That might not be the fastest possible solution in production, but it sure is nice for testing.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt; when HTTP_REQUEST { &lt;br /&gt;  &lt;br /&gt;    # Log a debug message with client IP:port and the class contents &lt;br /&gt;    log local0. "[IP::client_addr]:[TCP::client_port]: class \$::badStrings: $::badStrings" &lt;br /&gt;  &lt;br /&gt;    # Check if the client IP is part of the hosts datagroup &lt;br /&gt;    if { [matchclass [IP::server_addr] equals $::Hosts]}{ &lt;br /&gt;  &lt;br /&gt;       # Log a debug message indicating the client IP matched the Hosts class &lt;br /&gt;       log local0. "[IP::client_addr]:[TCP::client_port]: matched Hosts class \$::Hosts: $::Hosts" &lt;br /&gt;  &lt;br /&gt;       # Check if the requested URI contains any known bad strings &lt;br /&gt;       if { [matchclass [string tolower [HTTP::uri]] contains $::badStrings]}{  &lt;br /&gt;  &lt;br /&gt;          # Log a debug message indicating the client matched the Host class and had a bad string in the URI &lt;br /&gt;          log local0. "Matched server IP and found bad string in [HTTP::uri]: \&lt;br /&gt;entry# [matchclass [string tolower [HTTP::uri]] contains $::badStrings]"  &lt;br /&gt;  &lt;br /&gt; 	 # Drop the TCP connection	  &lt;br /&gt; 	 drop  &lt;br /&gt;       } &lt;br /&gt;    } &lt;br /&gt; } &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;MSM Whitelisting&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devcentral.f5.com/wiki/default.aspx/iRules/MSMBypass.html" title="http://devcentral.f5.com/wiki/default.aspx/iRules/MSMBypass.html"&gt;http://devcentral.f5.com/wiki/default.aspx/iRules/MSMBypass.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This codeshare entry shows how you can use an iRule to get even more out of MSM on your LTM. Oh how I love TLAs.  By creating a whitelist of known good IP addresses in this iRule, you can skip MSM processing and wring even more performance out of your BIG-IP...nice!&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;  priority 1&lt;br /&gt;  when CLIENT_ACCEPTED {  &lt;br /&gt;    if { [matchclass [IP::client_addr] equals $::white_list] } {  &lt;br /&gt;            log local0. "client: [IP::client_addr] found in white_list directed to http_test_pool"  &lt;br /&gt;          pool http_test_pool  &lt;br /&gt;          event disable all  &lt;br /&gt;    }  &lt;br /&gt;    elseif { [matchclass [IP::client_addr] equals $::black_list] } {  &lt;br /&gt;              log local0. " client: [IP::client_addr] found in black_list directed to http_test_pool_2"  &lt;br /&gt;          pool http_test_pool_2   &lt;br /&gt;                     # or discard  &lt;br /&gt;          event disable all  &lt;br /&gt;    }  &lt;br /&gt;  } &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Search and Replace via iRule&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=27079&amp;amp;view=topic" title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=27079&amp;amp;view=topic"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=27079&amp;amp;view=topic&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This example shows some of the things that can be done via the stream profile and selectively enabling replacements via iRules. The stream profile gives you plenty of ability to do data swapping in-line with even more speed than writing out the logic by hand in an iRule. Definitely good stuff.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font face="courier new"&gt;when HTTP_REQUEST {    &lt;br /&gt;
  set replace_content 0   &lt;br /&gt;
  if {[HTTP::uri] contains "/atoz/"} {    &lt;br /&gt;
    set replace_content 1    &lt;br /&gt;
  }    &lt;br /&gt;
}    &lt;br /&gt;
when HTTP_RESPONSE {   &lt;br /&gt;
  if {$replace_content equals "1"} {   &lt;br /&gt;
    # Disable the stream filter by default   &lt;br /&gt;
    STREAM::disable   &lt;br /&gt;
    # Check if response type is text   &lt;br /&gt;
    if {[HTTP::header value Content-Type] contains "text" and [HTTP::header "User-Agent"] contains "***"}{   &lt;br /&gt;
      # Replace   &lt;br /&gt;
      STREAM::expression "@123@xyz@ @456@xyz@"   &lt;br /&gt;
      # Enable the stream filter for this response only   &lt;br /&gt;
      STREAM::enable   &lt;br /&gt;
    }   &lt;br /&gt;
  }   &lt;br /&gt;
}&lt;/font&gt;    &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;There you have it, three more examples of iRules goodness in less than 20 lines each. See you next week.&lt;/p&gt;
&lt;div style="margin: 0px; padding: 0px; display: inline;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c906f882-3d0e-42e1-8407-21aad7500ed0" class="wlWriterSmartContent"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/20%20Lines%20or%20Less"&gt;20 Lines or Less&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/iRules"&gt;iRules&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/HTTP"&gt;HTTP&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Colin%20Walker"&gt;Colin Walker&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;#Colin&lt;/p&gt;&lt;div class='blogtags'&gt;&lt;/div&gt;&lt;img src="http://devcentral.f5.com/weblogs/cwalker/aggbug/3558.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Walker</dc:creator>
            <guid>http://devcentral.f5.com/weblogs/cwalker/archive/2008/08/22/20-lines-or-less-13.aspx</guid>
            <pubDate>Fri, 22 Aug 2008 23:35:17 GMT</pubDate>
            <wfw:comment>http://devcentral.f5.com/weblogs/cwalker/comments/3558.aspx</wfw:comment>
            <comments>http://devcentral.f5.com/weblogs/cwalker/archive/2008/08/22/20-lines-or-less-13.aspx#feedback</comments>
            <wfw:commentRss>http://devcentral.f5.com/weblogs/cwalker/comments/commentRss/3558.aspx</wfw:commentRss>
        </item>
        <item>
            <title>And all that jazz...</title>
            <link>http://devcentral.f5.com/weblogs/cwalker/archive/2008/07/27/and-all-that-jazz.aspx</link>
            <description>&lt;p&gt;It's been a while since I've been in the South. It's funny how some things came back almost immediately as fond memories. Even the heat and humidity felt comfortable from my years spent in Atlanta, so when I found myself in the midday New Orleans sun, it wasn't as bad as it would be for perhaps the average Seattle-ite with gills.&lt;/p&gt;
&lt;p&gt;Today I arrived in The Big Easy to help put on the iRules course at our annual Partner Summit. This is my first trip to New Orleans, and as an avid jazz/blues fan I have to say I'm excited for more reasons than just getting to share the good word about iRules/iControl/DevCentral. I'm really hoping I get the chance to get out and check out some awesome music while I'm here. If I get to have some awesome food while doing it, all the better.&lt;/p&gt;
&lt;p&gt;I'm even more excited because I get to be a co-presenter of some killer content (duh, it's about iRules, how could it be anything less?) with some really bright fellow F5ers, which should prove to be a truly hawesome experience. It's nice to feel so excited after having a little trepidation before coming down here.&lt;/p&gt;
&lt;p&gt;It's not that I don't like to travel, I love it, I don't even mind the flying or the airports, it's just that when I get back I get to go under the knife for a minor surgery, and I couldn't quite seem to get that out of my head. Low and behold, though, this trip is proving to be just the thing for it. I'm having fun so far, even though I just got here, catching up with the other iRulers that I'll be presenting with, and generally relaxing and getting out of my head. That's a good thing, so yeah....awesome.&lt;/p&gt;
&lt;p&gt;For any of you that might be attending, hope to see ya here! For those that aren't, I'll surely post more later.&lt;/p&gt;
&lt;div style="margin: 0px; padding: 0px; display: inline;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:6219de45-c48e-4bb4-b72d-4d18ba08719d" class="wlWriterSmartContent"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/DevCentral"&gt;DevCentral&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/iRules"&gt;iRules&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Blues"&gt;Blues&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Jazz"&gt;Jazz&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Colin%20Walker"&gt;Colin Walker&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;#Colin&lt;/p&gt;&lt;div class='blogtags'&gt;&lt;/div&gt;&lt;img src="http://devcentral.f5.com/weblogs/cwalker/aggbug/3489.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Walker</dc:creator>
            <guid>http://devcentral.f5.com/weblogs/cwalker/archive/2008/07/27/and-all-that-jazz.aspx</guid>
            <pubDate>Sun, 27 Jul 2008 19:46:48 GMT</pubDate>
            <wfw:comment>http://devcentral.f5.com/weblogs/cwalker/comments/3489.aspx</wfw:comment>
            <comments>http://devcentral.f5.com/weblogs/cwalker/archive/2008/07/27/and-all-that-jazz.aspx#feedback</comments>
            <wfw:commentRss>http://devcentral.f5.com/weblogs/cwalker/comments/commentRss/3489.aspx</wfw:commentRss>
        </item>
        <item>
            <title>20 Lines or Less #12</title>
            <link>http://devcentral.f5.com/weblogs/cwalker/archive/2008/07/24/20-lines-or-less-12.aspx</link>
            <description>&lt;p&gt;&lt;em&gt;What could you do with your code in 20 Lines or Less?&lt;/em&gt; That's the question I ask every week, and every week I go looking to find cool new examples that show just how flexible and powerful iRules can be without getting in over your head.&lt;/p&gt;  &lt;p&gt;Here we go again, three more examples of the powerful and interesting things you can do with iRules in less than 21 lines. Dipping again into the forums, with a few tweaks here and there (don't worry, I stayed honest to the rule, just took out comments and extra case comparisons, that kind of thing), we've got an action packed 20LoL this week.  Here we go:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;SSL iRule on a non-SSL VIP&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=26299&amp;amp;view=topic" href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=26299&amp;amp;view=topic"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=26299&amp;amp;view=topic&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This is a great example of using a single iRule for both HTTP and HTTPS traffic. In the forum post Deb shows a cool trick to allow us to sneak SSL commands past the iRule interpreter so that they are there when we need them, if a cert is found, but aren't used when the connection turns out to be straight HTTP.  Pretty cool stuff.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="courier new"&gt;when HTTP_REQUEST {        &lt;br /&gt;  HTTP::header replace ClientIP [IP::remote_addr]         &lt;br /&gt;  if {[PROFILE::exists clientssl] == 1} {         &lt;br /&gt;    set cname "SSL::cipher name"   &lt;br /&gt;    set cbits "SSL::cipher bits"   &lt;br /&gt;    set cver "SSL::cipher version"   &lt;br /&gt;    HTTP::header replace SSLCipher [eval $cname]:[eval $cbits]-[eval $cver]   &lt;br /&gt;    if { [SSL::cert count] &amp;gt; 0} {         &lt;br /&gt;      HTTP::header replace SSLSubject [b64encode [X509::subject [SSL::cert 0]]]         &lt;br /&gt;      HTTP::header replace SSLClientCert [b64encode [SSL::cert 0]]         &lt;br /&gt;      HTTP::header replace WebProtocol "HTTPS-auth"         &lt;br /&gt;    } else {         &lt;br /&gt;      HTTP::header replace WebProtocol "HTTPS"         &lt;br /&gt;    }         &lt;br /&gt;  } else {         &lt;br /&gt;    HTTP::header replace WebProtocol "HTTP"         &lt;br /&gt;  }         &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;    &lt;p&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;Extracting DHCP Info&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25727&amp;amp;view=topic" href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25727&amp;amp;view=topic"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25727&amp;amp;view=topic&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This example for extracting DHCP info is very specific. It's looking for option 82 (Support for Routed Bridge Encapsulation) which may not be particularly useful to everyone out there, but the example stands as a great display of how iRules can help you tear into almost any kind of data, even DHCP data, and make intelligent decisions or actions based on that. Sure, it might take some re-working for your purposes, but what a cool example to get started with!&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;when CLIENT_DATA {        &lt;br /&gt;  binary scan [UDP::payload] x240H* dhcp_option_payload         &lt;br /&gt;  set option 0         &lt;br /&gt;  set option_length [expr {([UDP::payload length] -240) * 2 }]         &lt;br /&gt;  for {set i 0} {$option != 52 &amp;amp;&amp;amp; $i &amp;lt; $option_length} {incr i [expr { $length * 2 +2 }]} {         &lt;br /&gt;    binary scan $dhcp_option_payload x[expr $i]a2 option         &lt;br /&gt;    incr i 2         &lt;br /&gt;    binary scan $dhcp_option_payload x[expr $i]a2 length_hex         &lt;br /&gt;    set length [expr 0x$length_hex]         &lt;br /&gt;  }         &lt;br /&gt;  if { $i &amp;lt; $option_length } {         &lt;br /&gt;    incr i -[expr { $length * 2 -2 }]         &lt;br /&gt;    binary scan $dhcp_option_payload x[expr $i]a2 length_hex         &lt;br /&gt;    set length [expr 0x$length_hex]         &lt;br /&gt;    incr i 2         &lt;br /&gt;    binary scan $dhcp_option_payload x[expr $i]a[expr { $length * 2 }] circuit_id         &lt;br /&gt;  } else {         &lt;br /&gt;    drop         &lt;br /&gt;  }         &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;    &lt;p&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;URI re-writing based on Load Balancing decision&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25791&amp;amp;view=topic" href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25791&amp;amp;view=topic"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25791&amp;amp;view=topic&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Talk about a chicken and egg demonstration. Hearing the title, you might think I have it backwards. When making this kind of decision in an iRule, the URI is often used to help make the load balancing decision. In this case, it's just the opposite. In this example we're letting the BIG-IP make a load balancing decision, then going back and updating the URI based on that decision, before the request is sent to the servers.  Very cool stuff!&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="courier new"&gt;when HTTP_REQUEST_SEND {        &lt;br /&gt;  set uri [string tolower [clientside {HTTP::uri}]]         &lt;br /&gt;  log local0. "[IP::client_addr]:[TCP::client_port]: selected server details: [LB::server] - \$uri: $uri"         &lt;br /&gt;  if {[IP::addr [LB::server addr] equals 10.207.225.101] or [IP::addr [LB::server addr] equals 10.207.225.102] or [IP::addr [LB::server addr] equals 10.207.225.103] }{         &lt;br /&gt;    log local0. "[IP::client_addr]:[TCP::client_port]: matched server check for .3 or .4"         &lt;br /&gt;    switch -glob [HTTP::uri] {         &lt;br /&gt;      "*/gsfo/gsfopub*" {         &lt;br /&gt;        clientside {HTTP::uri "/Async/CMReceive.ashx"}         &lt;br /&gt;        log local0. "[IP::client_addr]:[TCP::client_port]: updated URI to /Async/CMReceive.ashx"         &lt;br /&gt;      }         &lt;br /&gt;      "*/era/erapub*" {         &lt;br /&gt;        clientside {HTTP::uri "/Async/ERAReceive.ashx"}         &lt;br /&gt;        log local0. "[IP::client_addr]:[TCP::client_port]: updated URI to /Async/ERAReceive.ashx"         &lt;br /&gt;      }         &lt;br /&gt;      default {         &lt;br /&gt;        log local0. "[IP::client_addr]:[TCP::client_port]: didn't match URI checks"         &lt;br /&gt;      }         &lt;br /&gt;    }         &lt;br /&gt;  }         &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;    &lt;p&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;There you have it, the forums deliver yet again. I have to say I love checking out all these cool, new, compact examples of iRules goodness. Many thanks to the awesome &lt;a title="" href="http://devcentral.f5.com" target="_blank"&gt;DevCentral&lt;/a&gt; community for their continued contributions. I'll see you next week for another 20 Lines or Less.&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:562613d6-178b-4fc1-b788-51658534cdfd" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/DevCentral" rel="tag"&gt;DevCentral&lt;/a&gt;,&lt;a href="http://technorati.com/tags/20%20Lines%20or%20Less" rel="tag"&gt;20 Lines or Less&lt;/a&gt;,&lt;a href="http://technorati.com/tags/iRules" rel="tag"&gt;iRules&lt;/a&gt;,&lt;a href="http://technorati.com/tags/DHCP" rel="tag"&gt;DHCP&lt;/a&gt;,&lt;a href="http://technorati.com/tags/URI%20Rewriting" rel="tag"&gt;URI Rewriting&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SSL%20Information" rel="tag"&gt;SSL Information&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Colin%20Walker" rel="tag"&gt;Colin Walker&lt;/a&gt;&lt;/div&gt;  &lt;p&gt;#Colin&lt;/p&gt;&lt;div class='blogtags'&gt;&lt;/div&gt;&lt;img src="http://devcentral.f5.com/weblogs/cwalker/aggbug/3484.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Walker</dc:creator>
            <guid>http://devcentral.f5.com/weblogs/cwalker/archive/2008/07/24/20-lines-or-less-12.aspx</guid>
            <pubDate>Thu, 24 Jul 2008 22:51:31 GMT</pubDate>
            <wfw:comment>http://devcentral.f5.com/weblogs/cwalker/comments/3484.aspx</wfw:comment>
            <comments>http://devcentral.f5.com/weblogs/cwalker/archive/2008/07/24/20-lines-or-less-12.aspx#feedback</comments>
            <wfw:commentRss>http://devcentral.f5.com/weblogs/cwalker/comments/commentRss/3484.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Taco Tuesday with Jason Hoffman, Joyent CTO</title>
            <link>http://devcentral.f5.com/weblogs/cwalker/archive/2008/07/23/taco-tuesday-with-jason-hoffman-joyent-cto.aspx</link>
            <description>&lt;p&gt;So it looks like Joe and I are going to &lt;em&gt;have&lt;/em&gt; to take a trip down to San Fran to check out &lt;a target="_blank" href="http://www.yelp.com/biz/nicks-crispy-tacos-san-francisco"&gt;Nick's Crispy Tacos&lt;/a&gt; with &lt;a target="_blank" href="http://joyent.com/about/management-team/jason-a-hoffman/"&gt;Jason Hoffman&lt;/a&gt;, CTO and co-founder of &lt;a target="_blank" href="http://www.joyent.com/"&gt;Joyent&lt;/a&gt;. Jason puts on a "Taco Tuesday" on the third Tuesday of just about every month.  We've been invited down to check it out and geek out over the hawesome iRules/iControl/Ruby/*Nix/geeky stuff they're doing. Yeah...I'm not &lt;em&gt;completely&lt;/em&gt; geeking out and excited, honest. Don't worry though, we'll try to make the best of it.&lt;/p&gt;
&lt;p&gt;We got a fantastic opportunity today to talk with Jason about &lt;a target="_blank" href="http://www.joyent.com/"&gt;Joyent&lt;/a&gt;, what they're doing, their architecture, their background, etc. and how they're heavily leveraging F5 technology to make it all happen.  For those of you that don't know, Joyent is a long-time F5 customer that provides a wickedly cool, scalable, flexible cloud infrastructure to users ranging anywhere from the Mom and Pop size to truly robust Enterprise level applications. You may have seen &lt;a target="_blank" href="http://devcentral.f5.com/weblogs/Joe/archive/2008/07/15/scaling-ruby-on-rails-to-1-billion-page-views-a.aspx"&gt;Joe's blog post&lt;/a&gt; about Joyent hosting &lt;a target="_blank" href="http://www.linkedin.com/"&gt;LinkedIn's&lt;/a&gt; BumperSticker &lt;a target="_blank" href="http://www.linkedin.com/"&gt;Facebook&lt;/a&gt; app that recently surpassed a billion page views per month. That spurred an offer to chat, and Jason was more than happy to oblige.&lt;/p&gt;
&lt;p&gt;It was absolutely fantastic to talk to &lt;a target="_blank" href="http://joyent.com/about/management-team/jason-a-hoffman/"&gt;Jason&lt;/a&gt; who himself is an avid engineer that's got a long history with Unix and many of the flavors of coding that go along with it. As one of the first major adopters of &lt;a target="_blank" href="http://www.ruby-lang.org/en/"&gt;Ruby&lt;/a&gt; and, in fact, the very first person to check in source to the Rails source control system, he definitely knows what he's talking about when it comes to *Nix programming, Ruby, and &lt;a target="_blank" href="http://www.rubyonrails.org/"&gt;RoR&lt;/a&gt;. It turns out we even share a common love for and history with FreeBSD, go figure.&lt;/p&gt;
&lt;p&gt;Over the course of our discussion we got to chat with Jason about his role at &lt;a target="_blank" href="http://www.joyent.com/"&gt;Joyent&lt;/a&gt;, what they're delivering to users, why it's unique and powerful, obstacles they faced along they way, how they got around them which, I'm happy to say, largely included F5 technology and specifically iRules and iControl, and many other such things impressively full of win. From many of their security policies relying on iRules instead of FireWalls, to iControl being an integral part of their provisioning system, to building iRules as solutions to countless customer problems or requirements, these guys are definitely power users and avid &lt;a target="_blank" href="http://devcentral.f5.com" title=""&gt;DevCentral&lt;/a&gt; members, I'm happy to say.&lt;/p&gt;
&lt;p&gt;We also got to talk about the modern application, how it's architected, how the old school ways of thinking don't apply anymore and the massive benefits that can come from allowing yourself to see the possibilities with a modern, flexible, layered architecture. This architecture with powerful caches, application aware network devices serving large portions of the application functionality, and scalable, interchangeable back ends thanks to the load balancing that also occurs at that tier is hugely powerful and really more and more of a "must have" as things continue to progress in the application and application delivery world. Pretty darn cool stuff to hear from a PhD helping to run a hugely popular and successful hosting company. How's that for real world application?&lt;/p&gt;
&lt;p&gt; This is the &lt;em&gt;exact&lt;/em&gt; message I (we) have been pushing for a long time. Every time I talk about "preaching the good word", this is what I'm talking about. Times have changed, technology has improved, and F5 can be a big part of building a powerful, flexible, scalable, reliable architecture if you just let yourself think about things in the new, more modern world that Jason and Joyent have fully embraced. It's allowing them to be as powerful and usable as they are at extremely reasonable costs with incredible scalability as needed.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devcentral.f5.com/weblogs/interviews/archive/2008/07/23/scaling-in-the-cloud-with-joyents-jason-hoffman.aspx" target="_blank"&gt;Check out the podcast&lt;/a&gt; to get more of the details. Obviously I'm excited, and am currently trying to refrain from a big squeeeee of geekitude, but that's just how I get when I get to riff about awesome technology with even more awesome people.&lt;/p&gt;
&lt;p&gt;Stay tuned for the follow up where Joe and I tear into some tacos, margaritas and hopefully some iControl/Ruby/iRules with Jason down in his neck of the woods. Not that it's been approved yet or anything, but hey, I can hope, right?&lt;/p&gt;
&lt;p&gt;Thanks again Jason for the great chat, and keep up the killer work.&lt;/p&gt;
&lt;div style="margin: 0px; padding: 0px; display: inline;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:b093a7ea-b5c6-4e40-a68a-59e57375b847" class="wlWriterSmartContent"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/DevCentral"&gt;DevCentral&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/iRules"&gt;iRules&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/iControl"&gt;iControl&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Ruby"&gt;Ruby&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/iContRuby"&gt;iContRuby&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/LinkedIn"&gt;LinkedIn&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/FaceBook"&gt;FaceBook&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/BumperSticker"&gt;BumperSticker&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Joyent"&gt;Joyent&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Jason%20Hoffman"&gt;Jason Hoffman&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Colin%20Walker"&gt;Colin Walker&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;#Colin&lt;/p&gt;&lt;div class='blogtags'&gt;&lt;/div&gt;&lt;img src="http://devcentral.f5.com/weblogs/cwalker/aggbug/3479.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Walker</dc:creator>
            <guid>http://devcentral.f5.com/weblogs/cwalker/archive/2008/07/23/taco-tuesday-with-jason-hoffman-joyent-cto.aspx</guid>
            <pubDate>Wed, 23 Jul 2008 19:09:39 GMT</pubDate>
            <wfw:comment>http://devcentral.f5.com/weblogs/cwalker/comments/3479.aspx</wfw:comment>
            <comments>http://devcentral.f5.com/weblogs/cwalker/archive/2008/07/23/taco-tuesday-with-jason-hoffman-joyent-cto.aspx#feedback</comments>
            <wfw:commentRss>http://devcentral.f5.com/weblogs/cwalker/comments/commentRss/3479.aspx</wfw:commentRss>
        </item>
        <item>
            <title>20 Lines or Less #11</title>
            <link>http://devcentral.f5.com/weblogs/cwalker/archive/2008/07/16/20-lines-or-less-11.aspx</link>
            <description>&lt;p&gt;&lt;em&gt;What could you do with your code in 20 Lines or Less?&lt;/em&gt; That's the question I ask every week, and every week I go looking to find cool new examples that show just how flexible and powerful iRules can be without getting in over your head.&lt;/p&gt;
&lt;p&gt;This week's 20LoL comes care of both the codeshare and the forums alike.  I got to deal with a couple of particularly cool forum posts this week, one of which made the list, as did an iRule from the infamous hoolio himself. Dealing with HTTP and ranging from spiders to working around a work-week, these examples are yet more ways you can leverage iRules in less than 21 lines. Here we go:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Rate Limiting Search Spiders&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=26064&amp;amp;view=topic" href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=26064&amp;amp;view=topic"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=26064&amp;amp;view=topic&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Spiders on the web aren't the same pests as spiders in your house, but they can certainly have adverse effects if they're making an inordinate number of requests to your web-servers, and driving the load up.  Here's a cool example of how to avoid just that scenario. We've seen something similar a long time ago on &lt;a title="" href="http://devcentral.f5.com" target="_blank"&gt;DevCentral&lt;/a&gt; for Network Computing, but this is a good refresher. &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;when RULE_INIT { &lt;br /&gt;
  array set ::active_crawlers { } &lt;br /&gt;
  set ::min_interval 1 &lt;br /&gt;
} &lt;/font&gt; &lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;when HTTP_REQUEST { &lt;br /&gt;
  set user_agent [string tolower [HTTP::header "User-Agent"]] &lt;br /&gt;
  # Logic only relevant for crawler user agents &lt;br /&gt;
  if { [matchclass $user_agent contains $::Crawlers] } { &lt;br /&gt;
    # Throttle crawlers. &lt;br /&gt;
    set curr_time [clock seconds] &lt;br /&gt;
    if { [info exists ::active_crawlers($user_agent)] } { &lt;br /&gt;
      if { [ $::active_crawlers($user_agent) &amp;lt; $curr_time ] } { &lt;br /&gt;
        set ::active_crawlers($user_agent) [expr {$curr_time + $::min_interval}] &lt;br /&gt;
      } else { &lt;br /&gt;
        reject &lt;br /&gt;
      } &lt;br /&gt;
    } else { &lt;br /&gt;
      set ::active_crawlers($user_agent) [expr {$curr_time + $::min_interval}] &lt;br /&gt;
    } &lt;br /&gt;
  } &lt;br /&gt;
&lt;/font&gt;}&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Compression During the Work Week&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;view=topic&amp;amp;postid=25992" href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;view=topic&amp;amp;postid=25992"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;view=topic&amp;amp;postid=25992&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Coming through with a great example of how to have compression enabled only from 8AM-5PM, otherwise known as the normal US Workday, citizen_elah shows of his iRules kung fooery to help a fellow community member out. This same logic could be applied to almost anything else, besides compression, making this a great iRule to keep around in your back pocket.&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;when CLIENT_ACCEPTED {    &lt;br /&gt;  set time_r [split [clock format [clock seconds] -format {%k:%M} ] " "]  &lt;br /&gt;  set time_f [expr {[expr {[lindex $time_r 0]*100}] + [lindex $time_r 1]}]     &lt;br /&gt;  if { not(($time_f &amp;gt;= 800) &amp;amp;&amp;amp; ($time_f &amp;lt;= 1700)) } {     &lt;br /&gt;    set compression "off"    &lt;br /&gt;  }    &lt;br /&gt;}    &lt;br /&gt;        &lt;br /&gt;when HTTP_RESPONSE {     &lt;br /&gt;  if { $compression eq "off" } {    &lt;br /&gt;    COMPRESS::disable     &lt;br /&gt;  }     &lt;br /&gt;}     &lt;br /&gt;   &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;I then came through and offered some optional optimization, so I guess this could be considered your bonus-rule for the week.  It's easy when someone like elah does the legwork up front. ;) Check the link to see the extra example.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Fully Decode URI&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a title="http://devcentral.f5.com/wiki/default.aspx/iRules/FullyDecodeURI.html" href="http://devcentral.f5.com/wiki/default.aspx/iRules/FullyDecodeURI.html"&gt;http://devcentral.f5.com/wiki/default.aspx/iRules/FullyDecodeURI.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Representing the last leg of this HTTP tri-ath-a-post is an entry from our illustrious iRules CodeShare. This example shows how to be sure you're FULLY decoding your URI before processing. It correctly points out that sometimes encoded characters can contain encoded characters can contain encoded characters can contain....well, you get the point. See how one person decided to work around such issues in a scant 11 lines of code.&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;when HTTP_REQUEST {&lt;br /&gt;  # decode original URI.&lt;br /&gt;  set tmpUri [HTTP::uri]&lt;br /&gt;  set uri [URI::decode $tmpUri]&lt;br /&gt;&lt;br /&gt;  # repeat decoding until the decoded version equals the previous value.&lt;br /&gt;  while { $uri ne $tmpUri } {&lt;br /&gt;    set tmpUri $uri&lt;br /&gt;    set uri [URI::decode $tmpUri]&lt;br /&gt;  }&lt;br /&gt;  HTTP::uri $uri&lt;br /&gt;&lt;br /&gt;  log local0. "Original URI: [HTTP::uri]"&lt;br /&gt;  log local0. "Fully decoded URI: $uri"&lt;br /&gt;}&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;pre&gt; &lt;/pre&gt;
&lt;p&gt;&lt;font face="treb"&gt;There you have it, three more choice examples of iRules goodness in 20 Lines or Less.  Tune in again next week!&lt;/font&gt;&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:2f6d9a6d-cfcc-4f17-ad85-3698f83942ce" style="margin: 0px; padding: 0px; display: inline;"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/DevCentral" rel="tag"&gt;DevCentral&lt;/a&gt;,&lt;a href="http://technorati.com/tags/20%20Lines%20or%20Less" rel="tag"&gt;20 Lines or Less&lt;/a&gt;,&lt;a href="http://technorati.com/tags/HTTP" rel="tag"&gt;HTTP&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Colin%20Walker" rel="tag"&gt;Colin Walker&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;font face="treb"&gt;#Colin&lt;/font&gt;&lt;/p&gt;&lt;div class='blogtags'&gt;&lt;/div&gt;&lt;img src="http://devcentral.f5.com/weblogs/cwalker/aggbug/3460.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Walker</dc:creator>
            <guid>http://devcentral.f5.com/weblogs/cwalker/archive/2008/07/16/20-lines-or-less-11.aspx</guid>
            <pubDate>Thu, 17 Jul 2008 00:08:58 GMT</pubDate>
            <wfw:comment>http://devcentral.f5.com/weblogs/cwalker/comments/3460.aspx</wfw:comment>
            <comments>http://devcentral.f5.com/weblogs/cwalker/archive/2008/07/16/20-lines-or-less-11.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://devcentral.f5.com/weblogs/cwalker/comments/commentRss/3460.aspx</wfw:commentRss>
        </item>
        <item>
            <title>20 Lines or Less #10</title>
            <link>http://devcentral.f5.com/weblogs/cwalker/archive/2008/06/26/20-lines-or-less-10.aspx</link>
            <description>&lt;p&gt;&lt;em&gt;What could you do with your code in 20 Lines or Less?&lt;/em&gt; That's the question I ask every week, and every week I go looking to find cool new examples that show just how flexible and powerful iRules can be without getting in over your head.&lt;/p&gt;
&lt;p&gt;With another three examples of cool iRules, this week's 20 Lines or Less shows even more things you can do in less than 21 lines of code. I still haven't heard much from you guys as to the kinds of things you want to see, so make sure to get those requests in.  I can build all sorts of neat iRules if you just let me know what would be helpful or interesting.  Otherwise I might just make iRules that make iRules. Scary.&lt;/p&gt;
&lt;p&gt;This week we've got a couple forum examples and a contribution to the codeshare. Here's your epic, 10th edition of the 20LoL:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;HTTP Headers in the HTTP Response&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25423&amp;amp;view=topic" title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25423&amp;amp;view=topic"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25423&amp;amp;view=topic&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Dealing with HTTP headers is one of the most common tasks we see in iRules. One of the things that I've seen floating about the forums and elsewhere lately is the question of how to access that information in the Response portion of the HTTP transaction. Some people have had a problem with this, as many of those headers no longer exist (like, say, the host). It's a simple solution though, as you can see below...just use a variable to get you there.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font face="courier new"&gt;when HTTP_REQUEST { &lt;br /&gt;
  # Save the URI &lt;br /&gt;
  set uri [HTTP::uri] &lt;br /&gt;
}&lt;br /&gt;
when HTTP_RESPONSE { &lt;br /&gt;
  if {([HTTP::header Cache-Control] eq "private, max-age=3600") and ($uri ends_with “.html”)} { &lt;br /&gt;
    HTTP::header replace Cache-Control "public, max-age=3600" &lt;br /&gt;
  } &lt;br /&gt;
}&lt;/font&gt; &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Persistence equality in RDP sessions&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;&lt;a href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25271&amp;amp;view=topic" title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25271&amp;amp;view=topic"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25271&amp;amp;view=topic&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;This example solves an issue with mixing Linux and Windows based RDP sessions across a persistence enabled virtual Apparently there's an issue with trying to persist based off of the user string as some clients include &lt;a href="mailto:user@local.host"&gt;user@local.host&lt;/a&gt; and others just include the username. That's a bit of an issue.  iRules to the rescue, as always. &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font face="courier new"&gt;when CLIENT_ACCEPTED { &lt;br /&gt;
  TCP::collect &lt;br /&gt;
}  &lt;/font&gt; &lt;/p&gt;
&lt;p&gt;&lt;font face="courier new"&gt;when CLIENT_DATA {  &lt;br /&gt;
  TCP::collect 25  &lt;br /&gt;
  binary scan [TCP::payload] x11a* msrdp  &lt;br /&gt;
  if { [string equal -nocase -length 17 $msrdp "cookie: mstshash="] } {  &lt;br /&gt;
    set msrdp [string range $msrdp 17 end]  &lt;br /&gt;
    set len [string first "\n" $msrdp]  &lt;br /&gt;
    if { $len == -1 } { TCP::collect }  &lt;br /&gt;
    if { $msrdp contains "@" } {  &lt;br /&gt;
      if { $len &amp;gt; 5 } {  &lt;br /&gt;
        incr len -1  &lt;br /&gt;
        persist uie [getfield $msrdp "@" 1] 10800 &lt;br /&gt;
      }  &lt;br /&gt;
    } else { persist uie $msrdp 10800 }  &lt;br /&gt;
  }  &lt;br /&gt;
  TCP::release  &lt;br /&gt;
}&lt;/font&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Pool Selection based on File Extension&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devcentral.f5.com/wiki/default.aspx/iRules/PoolBasedOnExtension.html" title="http://devcentral.f5.com/wiki/default.aspx/iRules/PoolBasedOnExtension.html"&gt;http://devcentral.f5.com/wiki/default.aspx/iRules/PoolBasedOnExtension.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Taking a page from the codeshare, this iRule lets you build a correlation of file extensions and pools that serve those particular file types. This can be quite handy when dealing with large scale image servers, media systems, and especially systems that do things like dynamically generate watermarks on images and the like. Take a peek.&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;when HTTP_REQUEST {&lt;br /&gt;  switch -glob [HTTP::path] {&lt;br /&gt;    "*.jpg"        -&lt;br /&gt;    "*.gif"        -&lt;br /&gt;    "*.png"        { pool image_pool }&lt;br /&gt;    "*.pdf"        { pool pdf_pool }&lt;br /&gt;    default        { pool web_pool }&lt;br /&gt;  }&lt;br /&gt;}&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;pre&gt; &lt;/pre&gt;
&lt;p&gt;There you have it; three more examples in less than 60 lines of code. I hope you're still finding this series helpful. As always, feel free to drop me a line for feedback or suggestions.  Thanks!&lt;/p&gt;
&lt;div style="margin: 0px; padding: 0px; display: inline;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:621cd059-d5c3-4c84-ab2c-93e04694d8f8" class="wlWriterSmartContent"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/DevCentral"&gt;DevCentral&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/iRules"&gt;iRules&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/20%20Lines%20or%20Less"&gt;20 Lines or Less&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Persistence"&gt;Persistence&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/HTTP%20Headers"&gt;HTTP Headers&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Colin%20Walker"&gt;Colin Walker&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;#Colin&lt;/p&gt;&lt;div class='blogtags'&gt;&lt;/div&gt;&lt;img src="http://devcentral.f5.com/weblogs/cwalker/aggbug/3402.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Walker</dc:creator>
            <guid>http://devcentral.f5.com/weblogs/cwalker/archive/2008/06/26/20-lines-or-less-10.aspx</guid>
            <pubDate>Thu, 26 Jun 2008 20:58:50 GMT</pubDate>
            <wfw:comment>http://devcentral.f5.com/weblogs/cwalker/comments/3402.aspx</wfw:comment>
            <comments>http://devcentral.f5.com/weblogs/cwalker/archive/2008/06/26/20-lines-or-less-10.aspx#feedback</comments>
            <wfw:commentRss>http://devcentral.f5.com/weblogs/cwalker/comments/commentRss/3402.aspx</wfw:commentRss>
        </item>
        <item>
            <title>20 Lines or Less #9</title>
            <link>http://devcentral.f5.com/weblogs/cwalker/archive/2008/06/19/20-lines-or-less-9.aspx</link>
            <description>&lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;What could you do with your code in 20 Lines or Less?&lt;/em&gt; That's the question I ask every week, and every week I go looking to find cool new examples that show just how flexible and powerful iRules can be without getting in over your head.&lt;/p&gt;
&lt;p&gt;This week I've got a combination of entries from our awesome forum users, and a rule I wrote a while back to meet a certain need at the time. We're almost at 10 editions of the 20LoL, and I'm looking forward to many more. Hopefully you're still finding it interesting and useful. Shoot me a line and let me know what's good, what's bad, what can be better and what you want to hear about. &lt;/p&gt;
&lt;p&gt;In the meantime, here's this week's 20 Lines or Less&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Multi-Conditional Redirect&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25219&amp;amp;view=topic" title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25219&amp;amp;view=topic"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25219&amp;amp;view=topic&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Hoolio delivers this short and sweet iRules in the forums to show how you can use multiple pieces of data to decide when to perform a redirect.  Not only does he make use of a normal string comparison, but also an IP::addr comparison against the client's IP address. So in one line you're getting two comparisons on two different pieces of data. This is a good example for someone looking to redirect only a small subset of people, based on multiple pieces of data.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font face="courier new"&gt;when HTTP_REQUEST {        &lt;br /&gt;
   if { [string tolower [HTTP::path]] ends_with "/_grid/print/print_data.aspx" \&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new"&gt;   and (not ([IP::addr [IP::client_addr]/8 equals 10.0.0.0]))} {         &lt;br /&gt;
      HTTP::redirect "&lt;/font&gt;&lt;a href="http://google.com"&gt;&lt;font face="courier new"&gt;http://google.com"&lt;/font&gt;&lt;/a&gt;       &lt;br /&gt;
&lt;font face="courier new"&gt;   }        &lt;br /&gt;
}&lt;/font&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Syslog Priority Rewriting&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This is a variation on some actual code I wrote a while back to translate the syslog priority numbers when needed.  Depending on the different syslog configurations, these numbers may not line up. This can be a problem when you're trying to aggregate many syslog systems into one main log server. This iRule shows how you can catch these messages inline and modify them with whatever equation fits your environment.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;when CLIENT_DATA {        &lt;br /&gt;
  set pri [regexp -inline {&amp;lt;\d+&amp;gt;} [UDP::payload] ]         &lt;br /&gt;
  set newPri [expr ( ($pri - (($pri / 6) * 8) ) ) ]         &lt;br /&gt;
  regsub $pri [UDP::payload] $newPri newPayload         &lt;br /&gt;
  UDP::payload replace 0 [UDP::payload length] $newPayload         &lt;br /&gt;
}&lt;/font&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Duplicate Cookie Definitions&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25215&amp;amp;view=topic" title="http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25215&amp;amp;view=topic"&gt;http://devcentral.f5.com/Default.aspx?tabid=53&amp;amp;forumid=5&amp;amp;postid=25215&amp;amp;view=topic&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Going back to the forums, it seems that hoolio is at it again. In this cool example he shows a fellow community member how to check for and remove multiple Set-Cookie entries with the same name.  This way they can ensure that there is only one cookie present, regardless of how many times different apps may have tried to set it. This one looks a little long, but remove the comments and some of the white space, and it's under 20 lines...I checked.&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt; when HTTP_RESPONSE {   &lt;br /&gt;  &lt;br /&gt;    # Insert some test response headers &lt;br /&gt;    HTTP::header insert Set-Cookie {SESSIONID=AAAAAAAA; domain=.domain.com; path=/path/1} &lt;br /&gt;    HTTP::header insert Set-Cookie {keeper=don't delete; domain=.domain.com; path=/path/2} &lt;br /&gt;    HTTP::header insert Set-Cookie {SESSIONID=BBBBBBBB; domain=.domain.com; path=/path/3} &lt;br /&gt;    HTTP::header insert Set-Cookie {SESSIONID=CCCCCCCC; domain=.domain.com; path=/path/4} &lt;br /&gt;  &lt;br /&gt;    log local0. "Set-Cookie header values: [HTTP::header values Set-Cookie]" &lt;br /&gt;    log local0. "First Set-Cookie header which starts with SESSIONID: \&lt;br /&gt;      [lsearch -glob -inline [HTTP::header values Set-Cookie] "SESSIONID*"]" &lt;br /&gt;    log local0. "Last  Set-Cookie header which starts with SESSIONID: \&lt;br /&gt;      [lsearch -glob -inline -start end [HTTP::header values Set-Cookie] "SESSIONID*"]"&lt;br /&gt;  &lt;br /&gt;    set set_cookie_header [lsearch -glob -inline -start end [HTTP::header values Set-Cookie] "SESSIONID*"] &lt;br /&gt;    log local0. "\$set_cookie_header: $set_cookie_header" &lt;br /&gt;     &lt;br /&gt;    # Remove all SESSIONID cookies &lt;br /&gt;    while {[HTTP::cookie exists SESSIONID]}{ &lt;br /&gt;       HTTP::cookie remove SESSIONID &lt;br /&gt;    } &lt;br /&gt;    log local0. "Set-Cookie values: [HTTP::header values Set-Cookie]" &lt;br /&gt;  &lt;br /&gt;    # Re-insert the last SESSIONID Set-Cookie header	 &lt;br /&gt;    HTTP::header insert Set-Cookie $set_cookie_header &lt;br /&gt;     &lt;br /&gt;    log local0. "SESSIONID cookie: [HTTP::cookie SESSIONID]"    &lt;br /&gt; }&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;There you have it, 3 more examples in under 60 lines of code. Keep checking back every week to see what cool things can be done in just a few keystrokes. Many thanks to the awesome community and the people posting these examples. You're truly making DC a great place to be. &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div style="margin: 0px; padding: 0px; display: inline;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:6070fb94-b387-46a3-9e66-4b9a67c7ff3e" class="wlWriterSmartContent"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/DevCentral"&gt;DevCentral&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/iRules"&gt;iRules&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/20%20Lines%20or%20Less"&gt;20 Lines or Less&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Cookies"&gt;Cookies&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Redirects"&gt;Redirects&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Syslog"&gt;Syslog&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/UDP"&gt;UDP&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/HTTP"&gt;HTTP&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Colin%20Walker"&gt;Colin Walker&lt;/a&gt;&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;#Colin&lt;/p&gt;&lt;div class='blogtags'&gt;&lt;/div&gt;&lt;img src="http://devcentral.f5.com/weblogs/cwalker/aggbug/3375.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Walker</dc:creator>
            <guid>http://devcentral.f5.com/weblogs/cwalker/archive/2008/06/19/20-lines-or-less-9.aspx</guid>
            <pubDate>Thu, 19 Jun 2008 18:57:25 GMT</pubDate>
            <wfw:comment>http://devcentral.f5.com/weblogs/cwalker/comments/3375.aspx</wfw:comment>
            <comments>http://devcentral.f5.com/weblogs/cwalker/archive/2008/06/19/20-lines-or-less-9.aspx#feedback</comments>
            <wfw:commentRss>http://devcentral.f5.com/weblogs/cwalker/comments/commentRss/3375.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>