<?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/tag/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>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>

