What could you do with your code in 20 Lines or Less? That's the question I ask (almost) every week for the devcentral community, 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.

I’m back again this week with examples #135, 136 and 137 in the 20 Lines or Less series.  Chiming in this week are Chris Miller, Hoolio and Bhattman himself.  Three of our power users bringing you three cool chunks of iRule that get the job done.  This week we’ve got FTP Proxying and two forms of HTTP redirecting, both with different twists that make them interesting.  Let’s dig in.


iRule for Maintenance Page


This first example comes from Chris Miller. The general problem is a basic one: check the pool assigned to the given VIP to see if any nodes are up. If not, redirect to a maintenance page. Pretty boiler plate stuff.  What makes this one interesting is the way Chris went about answering the user’s other requirement which was to make sure this iRule could be applied to all of their virtuals without having to have an individual iRule for each.  Some handy use of the LB::server pool command allowed this to be an easy fix.  As I mentioned in the above thread, you could even add a class that stores an association of assigned pool –> maintenance URL to have the redirect by dynamically generated as well.