<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The F5 Guy &#187; iRule</title>
	<atom:link href="http://www.TheF5Guy.com/blog/index.php/category/irule/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.TheF5Guy.com/blog</link>
	<description>F5 BIG-IP, SharePoint and Other Technologies...</description>
	<lastBuildDate>Tue, 07 Feb 2012 15:11:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>iRule &#8211; The Art of War</title>
		<link>http://www.TheF5Guy.com/blog/2010/08/irule-the-art-of-war/</link>
		<comments>http://www.TheF5Guy.com/blog/2010/08/irule-the-art-of-war/#comments</comments>
		<pubDate>Sat, 14 Aug 2010 03:53:22 +0000</pubDate>
		<dc:creator>naladar</dc:creator>
				<category><![CDATA[BIG-IP]]></category>
		<category><![CDATA[iRule]]></category>
		<category><![CDATA[f5]]></category>
		<category><![CDATA[f5 MVP]]></category>
		<category><![CDATA[MVP Summit]]></category>

		<guid isPermaLink="false">http://www.TheF5Guy.com/blog/?p=1042</guid>
		<description><![CDATA[To use an iRule or to NOT use an iRule?  It seems like a simple question when first asked doesn&#8217;t it?  Yet when you reflect upon what you are really saying when you answer that question, you will realize a lot of thought should go into the answer. TMOS is gaining a wealth of new [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.TheF5Guy.com/blog/wp-content/uploads/2010/08/suntzu2.jpg"><img class="alignleft size-full wp-image-1054" title="suntzu2" src="http://www.TheF5Guy.com/blog/wp-content/uploads/2010/08/suntzu2.jpg" alt="" width="130" height="171" /></a>To use an iRule or to NOT use an iRule?  It seems like a simple question when first asked doesn&#8217;t it?  Yet when you reflect upon what you are really saying when you answer that question, you will realize a lot of thought should go into the answer.</p>
<p>TMOS is gaining a wealth of new functionality with each release and word of what you can achieve through using iRules is spreading even to those unfamiliar with the BIG-IP product line.  I have personally seen this discussion pop up more than once and we even grappled with it at the MVP Summit in Chicago.  <span id="more-1042"></span></p>
<p>I can&#8217;t help but reflect back on the book &#8220;The Art of War&#8221; by Sun Tzu when thinking about this subject.  During the summit I realized that we were pretty much attempting to do the same thing that Sun Tzu did.  To come up with tactics and lay out truths that could be relied upon to come to a logical decision about how to proceed.</p>
<p>With Sun Tzu, his end goal was to win the battle or war that he was fighting.  He wrote roughly 80 pages of tactics and guidelines for fighting war.  I think the same thing could be done simply to answer the question to use an iRule or to not.  The problem is that for those of us in the F5 community, is that generally speaking, we all have our own goals.</p>
<p>That makes setting guidelines to follow a little harder unless you first define two very important aspects.  I think the first question you should ask yourself is what is your role in your organization?  Secondly, what is the role of the F5 BIG-IP device(s) in your organization?</p>
<p>Something that I know without a doubt is that we all fill different roles in our respective companies and so do our BIG-IP devices.  There is no one size fits all answer to this unfortunately.  For those of you who are new to working the BIG-IP product line and those of you who have yet to set any real company policies regarding your use of iRules I have one small word of advice.  I urge you to sit down with your boss and talk about what you stance will be regarding iRules moving forward.  If you ARE the boss then I suggest thinking about this matter in depth and reflect not just on how it effects you but also your team.  I have no doubt that doing this in advance will save you a lot of trouble.</p>
<p>What are the topics you should think about?  What are all the possible gotchas that might come up?  It is again different for us all.  After having pondered this question myself, here are a few things I think one should keep in mind and discuss with their peers/boss:</p>
<p>1.  K.I.S.S. &#8211; That&#8217;s right, keep it simple stupid.  It&#8217;s a best practice that we should all follow.  The question though is this, will using an iRule make something simpler for you or more complex?  If it makes something simple it&#8217;s a no-brainer right?  It it makes things more complex?  Where do you draw the line?</p>
<p>2.  If you do use an iRule and you decide to do some complex logic in it, are you legally required to keep track of that code in an application code repository?  Different regulatory items will obviously apply depending on the nature of your business.  I know that in a lot of places that if one were to write complex iRules that changed the data that a customer see&#8217;s, then they would most certainly have to keep track of that.  Sometimes though, it is not external regulatory compliance but INTERNAL regulatory compliance that you have to think about.</p>
<p>3.  Who will support it?  If you write a really complex iRule who will support it in the future?  Are you prepared to redo an iRule at two o&#8217;clock in the morning because of a production update that a developer pushed out changed the code that your iRule relies upon?</p>
<p>4.  Let&#8217;s say that an opportunity to use an iRule has already presented itself.  Is it more cost productive for the business for the iRule writer to craft an iRule to fix the problem or to have the application programmers fix the problem in the code?</p>
<p>5.  What about your physical environment variables?  Can you implement this new iRule code without slowing down everyone else&#8217;s application traffic (provided you delivering multiple apps through it of course)?</p>
<p>6.  Perhaps it will come down to your boss looking at you and saying, &#8220;How comfortable are you writing an iRule to try to do this?&#8221;.  If that is the case and you are uncertain, then by all means head on over to the DevCentral forums and create a post about it!  You would be AMAZED at the things that people have done with iRules and AMAZED at how simple some of those things are to pull off!  iRules, it slices, it dices, it&#8230; well you get the idea.  Use the community to bounce ideas around because it can definitely help make that decision much easier for you to make.</p>
<p>7.  What approach should you take in general to iRule or not to iRule?  Should you take the look before you leap approach, always say yes or  always say no?  I am sure that most will pick the look before you leap approach just to  make certain they can do what they need to do using an iRule  programmatically, that they can do it efficiently and that doing so meets their other preset criteria.  It also may be that your role in the company and the role of your F5 BIG-IP device is strictly that of a networking device and iRules are not to be used or developed.  If that is the case, I would urge you to reconsider that stance and at least consider using some of the simpler iRules&#8230; please see comment #6 above.</p>
<p>I am sure there are a million more questions you can think of to ask that might be relevant to your current working conditions, this post is by no means a definitive guide.  Please feel free to add a comment to this post regarding things that may have helped you and your organization define your policy towards using or not using iRules.  I really would love to hear them.</p>
<p>It is wise to remember what Sun Tzu said of laying plans, &#8220;The general who wins a battle makes many calculations in his temple before the battle is fought.  The general who loses a battle makes but few calculations beforehand.  Thus do many calculations lead to victory, and few calculations to defeat; how much more no calculation at all.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.TheF5Guy.com/blog/2010/08/irule-the-art-of-war/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iRules &#8211; Transparent Header Modification</title>
		<link>http://www.TheF5Guy.com/blog/2010/06/irules-transparent-header-modification/</link>
		<comments>http://www.TheF5Guy.com/blog/2010/06/irules-transparent-header-modification/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 03:12:44 +0000</pubDate>
		<dc:creator>naladar</dc:creator>
				<category><![CDATA[BIG-IP]]></category>
		<category><![CDATA[iRule]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[f5]]></category>

		<guid isPermaLink="false">http://www.TheF5Guy.com/blog/?p=979</guid>
		<description><![CDATA[Time and time again I am amazed at how powerful and flexible iRules can be. I have seen a few posts on DevCentral requesting help with creating iRules that rewrite or redirect traffic without updating the clients browser and I thought it might be fun to provide a few examples of how to do this. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.TheF5Guy.com/blog/wp-content/uploads/2010/06/detour1.jpg"><img class="alignleft size-full wp-image-986" title="detour" src="http://www.TheF5Guy.com/blog/wp-content/uploads/2010/06/detour1.jpg" alt="" width="179" height="81" /></a>Time and time again I am amazed at how powerful and flexible iRules can be.  I have seen a few posts on DevCentral requesting help with creating iRules that rewrite or redirect traffic without updating the clients browser and I thought it might be fun to provide a few examples of how to do this.</p>
<p>One way to do this is called transparent header modification.  How it works is a user will enter a URL in their browser such as &#8220;www.mycompany.com/bus/&#8221;, the request will come in to your BIG-IP and the information sent to your web servers can be redirected or rewritten to whatever you like.  Here is an example:<span id="more-979"></span></p>
<p><code><br />
when HTTP_REQUEST {<br />
switch -glob [string tolower [HTTP::uri] ] {<br />
"/bus/*" {<br />
HTTP::uri "/greyhound/bus"<br />
}<br />
}<br />
}<br />
</code></p>
<p>Using the iRule above, this is what happens to your incoming HTTP request.  The request comes in and the URI is converted to lower case and then inspected to see if it begins with &#8220;/bus/&#8221;.  The asterisk indicates a wildcard, so anything could come after &#8220;/bus/&#8221;.  If it does begin with &#8220;/bus/&#8221; then the URI will be transparently modified or changed to &#8220;/greyhound/bus&#8221;.  The clients browser will not be updated, but the URI that the BIG-IP passes on to the server will be &#8220;/greyhound/bus&#8221;.  Basically it turns a request for this &#8220;www.mycompany.com/bus/myrequest&#8221; INTO &#8220;www.mycompany.com/greyhound/bus&#8221;  Pretty cool huh?</p>
<p>Now lets say you want to do something a little more exotic.  Lets use the iRule from above in a different way.</p>
<p><code><br />
when HTTP_REQUEST {<br />
set uri [HTTP::uri]<br />
switch -glob [string tolower [HTTP::uri] ] {<br />
"/bus/*" {<br />
HTTP::uri "/greyhound/searchBus.do?stationName=[string range $uri 5 end]"<br />
}<br />
}<br />
}<br />
</code></p>
<p>What is this one doing?  Let say an HTTP request comes in for &#8220;www.mycompany.com/bus/texas&#8221;.  Using the iRule above the web server would actually receive a request for &#8220;www.mycompany.com/greyhound/searchBus.do?stationName=texas&#8221;.  The clients browser would still read &#8220;www.mycompany.com/bus/texas&#8221;.  Like I said powerful and flexible.</p>
<p>If you are interested in more content regarding transparent header modifications a.k.a. redirecting users without changing their URL, then I recommend reading this article by Joe Pruitt on the DevCentral website <a href="http://devcentral.f5.com/weblogs/Joe/archive/2005/07/27/ModifyingUriWithoutRedirect.aspx">http://devcentral.f5.com/weblogs/Joe/archive/2005/07/27/ModifyingUriWithoutRedirect.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.TheF5Guy.com/blog/2010/06/irules-transparent-header-modification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cookie Encryption Using An iRule</title>
		<link>http://www.TheF5Guy.com/blog/2010/01/cookie-encryption-using-an-irule/</link>
		<comments>http://www.TheF5Guy.com/blog/2010/01/cookie-encryption-using-an-irule/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 04:17:22 +0000</pubDate>
		<dc:creator>naladar</dc:creator>
				<category><![CDATA[BIG-IP]]></category>
		<category><![CDATA[iRule]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[f5]]></category>

		<guid isPermaLink="false">http://www.TheF5Guy.com/blog/?p=816</guid>
		<description><![CDATA[I was going through the database of articles on AskF5 today and found an awesome feature that I wanted to highlight.  My interest was first sparked because of an article that Lori MacVittie about cookie encryption.  That article can be found here. So that got me to thinking&#8230; how can someone do this in an [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.TheF5Guy.com/blog/wp-content/uploads/2010/01/cookieencryption.jpg"><img class="alignright size-thumbnail wp-image-823" title="cookieencryption" src="http://www.TheF5Guy.com/blog/wp-content/uploads/2010/01/cookieencryption-150x135.jpg" alt="" width="125" height="112" /></a>I was going through the database of articles on AskF5 today and found an awesome feature that I wanted to highlight.  My interest was first sparked because of an article that Lori MacVittie about cookie encryption.  That article can be found <a title="Lori's article on cookies" href="http://devcentral.f5.com/weblogs/macvittie/archive/2010/01/15/google-gmail-ssl-cookie-encryption.aspx" target="_blank">here</a>.</p>
<p>So that got me to thinking&#8230; how can someone do this in an iRule?  I have to admit I haven&#8217;t really looked into it that much previously because we utilize an ASM module running on a 4100 unit.  The 4100 can do a lot of different things regarding cookies such as checking if a cookie has been modified and if the cookie was obtained in a previous session.  I figured I would hit the AskF5 database to see what I could turn up and I uncovered this little gem:<span id="more-816"></span></p>
<p><code>when RULE_INIT {<br />
set ::key [AES::key 128]<br />
}<br />
when HTTP_RESPONSE {<br />
set decrypted [HTTP::cookie "MyCookie"]<br />
HTTP::cookie remove "MyCookie"<br />
set encrypted [b64encode [AES::encrypt $::key $decrypted]]<br />
HTTP::cookie insert name "MyCookie" value $encrypted<br />
}<br />
when HTTP_REQUEST {<br />
set encrypted [HTTP::cookie "MyCookie"]<br />
HTTP::cookie remove "MyCookie"<br />
set decrypted [AES::decrypt $::key [b64decode $encrypted]]<br />
HTTP::cookie insert name "MyCookie" value $decrypted<br />
}</code></p>
<p>There is definitely more to this, so you may want to go check out the full solution article here:  <a title="Solution Article" href="https://support.f5.com/kb/en-us/solutions/public/7000/700/sol7784.html">SOL7784</a>.  There is also an awesome 2009 iRule Contest entry that you should check out <a title="2nd Place iRule Winner" href="http://devcentral.f5.com/Default.aspx?tabid=2228">here.</a> The iRule you will want to look at is the Cookie Tampering Prevention iRule written by Henrik Gyllkrans.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.TheF5Guy.com/blog/2010/01/cookie-encryption-using-an-irule/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>2009 iRule Contest</title>
		<link>http://www.TheF5Guy.com/blog/2009/10/2009-irule-contest/</link>
		<comments>http://www.TheF5Guy.com/blog/2009/10/2009-irule-contest/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 19:44:27 +0000</pubDate>
		<dc:creator>naladar</dc:creator>
				<category><![CDATA[iRule]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[BIG-IP]]></category>
		<category><![CDATA[f5]]></category>

		<guid isPermaLink="false">http://www.TheF5Guy.com/blog/?p=619</guid>
		<description><![CDATA[It&#8217;s that time of year again&#8230; the leaves are changing, little kids are running around all painted up and the iRule contest finalists have been announced!  From browsing the finalists entries, it is safe to say that the judges must have had there hands full this year with many excellent submissions.  If you haven&#8217;t casted [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-635" href="http://www.TheF5Guy.com/blog/2009/10/2009-irule-contest/thef5guy-4/"><a rel="attachment wp-att-671" href="http://www.TheF5Guy.com/blog/?attachment_id=671"><img class="alignleft size-medium wp-image-671" title="sitelogo1" src="http://www.TheF5Guy.com/blog/wp-content/uploads/2009/10/sitelogo11-240x300.png" alt="sitelogo1" width="192" height="240" /></a></a>It&#8217;s that time of year again&#8230; the leaves are changing, little kids are running around all painted up and the iRule contest finalists have been announced!  From browsing the finalists entries, it is safe to say that the judges must have had there hands full this year with many excellent submissions.  If you haven&#8217;t casted your vote yet, get over there, browse the selection and help choose the winner!  Here is a direct link: <a title="Cast Your Vote" href="http://devcentral.f5.com/Default.aspx?tabid=2225" target="_blank">http://devcentral.f5.com/Default.aspx?tabid=2225</a></p>
<p>A friend of mine supplied the image to the left.  I am thinking that it may have to be the official logo for my website!  Of course, had I known he was taking pictures of me with his cell phone I would have flexed a bit more&#8230;</p>
<p>Not buying that are you?  Well OK, maybe that is just what I look like in my mind!  Coming next week to &#8220;The F5 Guy&#8221; website, news and reviews straight from the Dallas SecureWorld Expo!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.TheF5Guy.com/blog/2009/10/2009-irule-contest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using not In An iRule</title>
		<link>http://www.TheF5Guy.com/blog/2009/08/using_not_in_an_irule/</link>
		<comments>http://www.TheF5Guy.com/blog/2009/08/using_not_in_an_irule/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 05:01:56 +0000</pubDate>
		<dc:creator>naladar</dc:creator>
				<category><![CDATA[BIG-IP]]></category>
		<category><![CDATA[iRule]]></category>
		<category><![CDATA[f5]]></category>
		<category><![CDATA[how to]]></category>

		<guid isPermaLink="false">http://www.TheF5Guy.com/blog/?p=291</guid>
		<description><![CDATA[Sometimes a people just make things harder than they have to be.  Myself included unfortunately.  Not long ago, I was given the task to write an iRule that would scan the URL of an incoming HTTP request and redirect it to a new location.  No problem right?  I have done that a million times as [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-medium wp-image-296 alignleft" title="homer_simpson" src="http://www.TheF5Guy.com/blog/wp-content/uploads/2009/08/homer_simpson-249x300.jpg" alt="homer_simpson" width="119" height="144" />Sometimes a people just make things harder than they have to be.  Myself included unfortunately.  Not long ago, I was given the task to write an iRule that would scan the URL of an incoming HTTP request and redirect it to a new location.  No problem right?  I have done that a million times as I am sure most of you out there have as well.  Here&#8217;s the catch.  It turns out I would need to scan the URL for a value that was <span style="text-decoration: underline;">NOT</span> there.</p>
<p>Now this was an afront to my logic!  My brain was so used to thinking &#8220;If this, then this&#8221;, that it really was hard for me to wrap my brain around how I was going to pull this off.  So of course, I did what any sane F5&#8242;er does when he is looking for an answer to a puzzle he cannot solve.  I turned to <a title="F5 DevCentral" href="http://devcentral.f5.com/" target="_blank">Devcentral</a> and the community forums.  I dug around for a while and eventually I found an old 4.0 iRule where an individual had used the &#8220;not&#8221; Logical Operator.</p>
<p><span id="more-291"></span> So I gave myself a big slap on the forehead and muttered a Homer Simpson&#8217;ish &#8220;DOH!!&#8221;.  I later went on to discover that the &#8220;not&#8221; Logical Operator is well documented on DevCentral <a title="Not Logical Operator" href="http://devcentral.f5.com/Wiki/default.aspx/iRules/not.html">here</a>.  Below is the simple iRule that has saved our company thousands of dollars, saved the help desk many man hours of labor, prevented users from going insane because of broken links and keeps things simple.  It is amazing how an iRule so simple, can have such a dramatic impact.  So, the next time you are writing an iRule, just think of all the things you could &#8220;NOT&#8221; be doing!</p>
<p><code><br />
<span style="color: #00ff00;">when HTTP_REQUEST {<br />
if { not ([string tolower [HTTP::host]] contains ".mycompany.com")}{<br />
HTTP::redirect "https://[HTTP::host].mycompany.com[HTTP::uri]"<br />
}<br />
}</span><br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.TheF5Guy.com/blog/2009/08/using_not_in_an_irule/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Cookie Persistence, a sticky situation&#8230;</title>
		<link>http://www.TheF5Guy.com/blog/2009/02/irule-persistence/</link>
		<comments>http://www.TheF5Guy.com/blog/2009/02/irule-persistence/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 03:13:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[BIG-IP]]></category>
		<category><![CDATA[iRule]]></category>
		<category><![CDATA[Cookie Persistence]]></category>
		<category><![CDATA[f5]]></category>

		<guid isPermaLink="false">http://www.Thef5Guy.com/?p=84</guid>
		<description><![CDATA[Sorry folks, but you just have to have a horrible pun thrown at you from time to time!  All joking aside, today I worked on resolving a persistence issue to a few Citrix gateways that are load balanced by a BIG-IP® 6400.  I discovered that it is possible to use both a default persistence profile [...]]]></description>
			<content:encoded><![CDATA[<p>Sorry folks, but you just have to have a horrible pun thrown at you from time to time!  All joking aside, today I worked on resolving a persistence issue to a few Citrix gateways that are load balanced by a BIG-IP® 6400.  I discovered that it is possible to use both a default persistence profile and to specify persistence in an iRule, all on the same Virtual Server.</p>
<p>Bearing in mind that I have the &#8220;Default Persistence Profile&#8221; set to use a profile other than cookie, here is the iRule that I wrote:</p>
<pre class="code"><span style="color: #00ff00;"> when HTTP_REQUEST {
 set header_uri [string tolower [HTTP::uri]]
 if { [matchclass $header_uri starts_with $::aaa_uri] } {
 	pool aaa_Pool
 } elseif { [matchclass $header_uri starts_with $::bbb_uri] } {
 	HTTP::redirect "https://bbb.companyname.com/bbb/main/Main.jsp"
 } elseif { [matchclass $header_uri starts_with $::CITRIX_uri] } {
 	persist cookie insert "CITRIX_Cookie" "0d 03:00:00"
 	pool CITRIX_Pool
 } else {
   pool ccc_Pool
  }
 } </span></pre>
<p>The command persist cookie insert &#8220;CITRIX_Cookie&#8221; &#8220;0d 03:00:00&#8243;, tells the BIG-IP® to create a cookie named CITRIX_Cookie, give it a duration of 3 hours and insert it into the header of traffic going to the CITRIX_Pool.  If traffic going to that pool already has the CITRIX_Cookie in its header then persist the connection to the same pool member that it used last time.</p>
<p>Traffic going to the rest of the pools will use whatever persistence method is set in the &#8220;Default Persistence Profile&#8221;.  It is also possible to disable persistence to pools by using the <span style="color: #00ff00;">persist none</span> command.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.TheF5Guy.com/blog/2009/02/irule-persistence/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

