For those not in the know we here at F5 take training our field folks pretty seriously. Every time there is a new batch of Field Sales Engineers (FSEs) - the people that head from customer to customer to make the magic happen, showing off what F5 technology can really do - we bring them out to Seattle for a two week, intensive, no holds barred session of drinking from the fire hose training. During this time they go through training at the hands of some of F5’s top experts on a variety of subjects. Each different technology, presentation styles, the market and what is happening currently to name just a few. It just so happens that one of the topics that has come to be a requested portion of the curriculum is this little iRules Challenge that started out as a one off on a whim from one of the awesome people putting on the boot camp.
Here’s how it works: I dream up some imaginary customer scenario. Something that is conceivable for a field engineer to run into. I then lay out some requirements, and ask each engineer to solve the problem using an iRule. Mind you these people are all brand new to F5, most have little or no programming background, and I’m not necessarily playing nice with these requirements. They get a week to submit an entry, and then I judge the entries to select the top 3 for fabulous gifts and prizes (see: f5 swag). What started out as a one off is now part of the core content of the boot camp, and apparently FSE managers around the world are watching to see who wins, and cheer on the new FSEs from their region. Pretty awesome right?
So that brings us to today. Last week I had the pleasure of judging another FSE iRules challenge, and I’m here to put the winners on display to the masses as they so rightly deserve. This time around the top 2 spots were decided as narrowly as they ever have been, as both were really solid entries. Everyone that submitted an entry should be proud though, and keep on kicking tail with iRules, because every single one showed promise and a solid understanding of the concepts required to solve such a problem, especially considering some of these folks have only been with F5 for a matter of weeks.
First let’s cover what the challenge was:
Scenario: A client needs to build in application specific redirects based on the URI, as well as query specific rewriting that is transparent to end users.
Desired Solution:
- Any request to domain.com/app[1-20] should be permanently redirected to domain.com/newapp[1-20]
- Any request to domain.com/ should be re-written for the back end as domain.com/newapp[1-20]?user=
- This will require you to check / against a list of known users, and reference which application (newapp1-20) they should be associated with.
- You will need to build this list of users and relate them to applications such as:
- Bob → 20
- Joe → 10
- Sally →
- So domain.com/bob → domain.com/newapp20?user=bob
- Any response bound for the user that directs the user to domain.com/newapp[1-20]?user= must be re-written to the requesting format of domain.com/
- All traffic to this VIP should be SSL only, including redirects where needed.
Like I said, these aren’t kiddy pool style challenges. These are “Hi, how are you? Good to meet you. This is the deep end, enjoy your swim” style challenges. Meek need not apply. Now then, on to the winners!
Third Place - Clive Chan
Clive’s iRule showed a solid understanding of the basic redirection portion of the challenge, and with some more time I’m confident that he’ll be cranking out complete iRule solutions in the field.
<span id="lnum1" style="color: #606060;"> 1:</span> <span style="color: #0000ff;">when</span> <span style="color: #cc6633;">HTTP_REQUEST</span> {
<span id="lnum2" style="color: #606060;"> 2:</span> <span style="color: #0000ff;">if</span> {[<span style="color: #0000ff;">class</span> match [<span style="color: #0000ff;">HTTP::uri</span>] <span style="color: #0000ff;">equals</span> Oldapp]}{
<span id="lnum3" style="color: #606060;"> 3:</span> <span style="color: #0000ff;">HTTP::respond</span> 301 Location <span style="color: #006080;">"https://[getfield [HTTP::host] "</span>:<span style="color: #006080;">" 1][class search -value Oldapp equals [HTTP::uri]]"</span>
<span id="lnum4" style="color: #606060;"> 4:</span> <span style="color: #0000ff;">log</span> local0. <span style="color: #006080;">"domain.com/app\[1-20\] permanently redirected to domain.com/newapp\[1-20\]"</span>
<span id="lnum5" style="color: #606060;"> 5:</span> } <span style="color: #0000ff;">elseif</span> {[<span style="color: #0000ff;">class</span> match [<span style="color: #0000ff;">HTTP::uri</span>] <span style="color: #0000ff;">equals</span> Userapp]}{
<span id="lnum6" style="color: #606060;"> 6:</span>
<span id="lnum7" style="color: #606060;"> 7:</span> <span style="color: #0000ff;">set</span> username [<span style="color: #0000ff;">getfield</span> [<span style="color: #0000ff;">HTTP::uri</span>] <span style="color: #006080;">"/"</span> 2]
<span id="lnum8" style="color: #606060;"> 8:</span> <span style="color: #0000ff;">set</span> appnum [<span style="color: #0000ff;">class</span> search -value Userapp <span style="color: #0000ff;">equals</span> [<span style="color: #0000ff;">HTTP::uri</span>]]
<span id="lnum9" style="color: #606060;"> 9:</span>
<span id="lnum10" style="color: #606060;"> 10:</span> <span style="color: #0000ff;">HTTP::uri</span> /newapp$appnum?user=$username
<span id="lnum11" style="color: #606060;"> 11:</span> <span style="color: #0000ff;">HTTP::redirect</span> <span style="color: #006080;">"https://[HTTP::host][HTTP::uri]"</span>
<span id="lnum12" style="color: #606060;"> 12:</span> <span style="color: #0000ff;">log</span> local0. <span style="color: #006080;">"domain.com/$username re-written for the back end as domain./newapp$appnum?user=$username"</span>
<span id="lnum13" style="color: #606060;"> 13:</span> } <span style="color: #0000ff;">else</span> {
<span id="lnum14" style="color: #606060;"> 14:</span> <span style="color: #0000ff;">HTTP::redirect</span> <span style="color: #006080;">"https://[HTTP::host][HTTP::uri]"</span>
<span id="lnum15" style="color: #606060;"> 15:</span> <span style="color: #0000ff;">log</span> local0. <span style="color: #006080;">"Directed Traffic to SSL"</span>
<span id="lnum16" style="color: #606060;"> 16:</span> }
<span id="lnum17" style="color: #606060;"> 17:</span> }
Second Place - Rubyanne Deang
This iRule was at the top of my list, destined to be the winner until the very last minute when it just barely got bumped into second place. It was a heck of a race and Rubyanne shows some serious promise to be an iRules ninja in no time. She was also asking the most questions out of anyone in the group, which I see as a sign of great things to come. That hunger for knowledge and willingness to seek it out are powerful things.
<span id="lnum1" style="color: #606060;"> 1:</span> <span style="color: #0000ff;">priority</span> 50
<span id="lnum2" style="color: #606060;"> 2:</span> <span style="color: #0000ff;">when</span> <span style="color: #cc6633;">HTTP_REQUEST</span> {
<span id="lnum3" style="color: #606060;"> 3:</span>
<span id="lnum4" style="color: #606060;"> 4:</span> <span style="color: #008000;">## Disable the stream filter by default</span>
<span id="lnum5" style="color: #606060;"> 5:</span> <span style="color: #0000ff;">STREAM::disable</span>
<span id="lnum6" style="color: #606060;"> 6:</span>
<span id="lnum7" style="color: #606060;"> 7:</span> <span style="color: #0000ff;">set</span> internal_uri <span style="color: #006080;">""</span>
<span id="lnum8" style="color: #606060;"> 8:</span>
<span id="lnum9" style="color: #606060;"> 9:</span> <span style="color: #008000;">## Check for a URI of /</span>
<span id="lnum10" style="color: #606060;"> 10:</span> <span style="color: #008000;">## Do some minimal validation of the URI before trying to parse the username</span>
<span id="lnum11" style="color: #606060;"> 11:</span>
<span id="lnum12" style="color: #606060;"> 12:</span> <span style="color: #0000ff;">if</span> {[<span style="color: #0000ff;">HTTP::uri</span>] eq <span style="color: #006080;">"/"</span> <span style="color: #0000ff;">or</span> [<span style="color: #0000ff;">HTTP::uri</span>] <span style="color: #0000ff;">contains</span> <span style="color: #006080;">"."</span>}{
<span id="lnum13" style="color: #606060;"> 13:</span>
<span id="lnum14" style="color: #606060;"> 14:</span> <span style="color: #008000;"># Exit this event in this rule as the URI is not in the form of /</span>
<span id="lnum15" style="color: #606060;"> 15:</span> <span style="color: #0000ff;">return</span>
<span id="lnum16" style="color: #606060;"> 16:</span> }
<span id="lnum17" style="color: #606060;"> 17:</span>
<span id="lnum18" style="color: #606060;"> 18:</span> <span style="color: #008000;">## Split the URI into a TCL list on each forward slash. Examples:</span>
<span id="lnum19" style="color: #606060;"> 19:</span> <span style="color: #0000ff;">set</span> uri_list [<span style="color: #0000ff;">split</span> [<span style="color: #0000ff;">HTTP::uri</span>] /]
<span id="lnum20" style="color: #606060;"> 20:</span>
<span id="lnum21" style="color: #606060;"> 21:</span> <span style="color: #008000;">## Check if the URI split contains two elements</span>
<span id="lnum22" style="color: #606060;"> 22:</span> <span style="color: #0000ff;">if</span> {[<span style="color: #0000ff;">llength</span> $uri_list] == 2}{
<span id="lnum23" style="color: #606060;"> 23:</span>
<span id="lnum24" style="color: #606060;"> 24:</span> <span style="color: #008000;">## Parse 'app' from the second list element</span>
<span id="lnum25" style="color: #606060;"> 25:</span> <span style="color: #0000ff;">set</span> app [<span style="color: #0000ff;">lindex</span> $uri_list 1]
<span id="lnum26" style="color: #606060;"> 26:</span> <span style="color: #0000ff;">log</span> local0. <span style="color: #006080;">"uri: [HTTP::uri], parsed \$app: $app"</span>
<span id="lnum27" style="color: #606060;"> 27:</span> }
<span id="lnum28" style="color: #606060;"> 28:</span>
<span id="lnum29" style="color: #606060;"> 29:</span> <span style="color: #008000;">## when a request comes in and URI matches app[1-20]</span>
<span id="lnum30" style="color: #606060;"> 30:</span> <span style="color: #0000ff;">set</span> newapp [<span style="color: #0000ff;">class</span> match -value [<span style="color: #0000ff;">HTTP::uri</span>] <span style="color: #0000ff;">ends_with</span> app_class]
<span id="lnum31" style="color: #606060;"> 31:</span> <span style="color: #0000ff;">set</span> newapp_value [<span style="color: #0000ff;">class</span> match -value $app <span style="color: #0000ff;">equals</span> username_class]
<span id="lnum32" style="color: #606060;"> 32:</span>
<span id="lnum33" style="color: #606060;"> 33:</span> <span style="color: #0000ff;">log</span> local0. <span style="color: #006080;">"NEWAPP equals $newapp"</span>
<span id="lnum34" style="color: #606060;"> 34:</span> <span style="color: #0000ff;">log</span> local0. <span style="color: #006080;">"NEW APP VALUE equal $newapp_value"</span>
<span id="lnum35" style="color: #606060;"> 35:</span>
<span id="lnum36" style="color: #606060;"> 36:</span> <span style="color: #0000ff;">if</span> {$app ne <span style="color: #006080;">""</span> && $newapp ne <span style="color: #006080;">""</span>}{
<span id="lnum37" style="color: #606060;"> 37:</span>
<span id="lnum38" style="color: #606060;"> 38:</span> <span style="color: #008000;">## Assign newapp variable with the matching URI</span>
<span id="lnum39" style="color: #606060;"> 39:</span>
<span id="lnum40" style="color: #606060;"> 40:</span> <span style="color: #0000ff;">log</span> local0. <span style="color: #006080;">"This is the [HTTP::uri] and this is the the new URL https://domain.com/$newapp"</span>
<span id="lnum41" style="color: #606060;"> 41:</span>
<span id="lnum42" style="color: #606060;"> 42:</span> <span style="color: #008000;">## Issue a permanent redirect to new URI</span>
<span id="lnum43" style="color: #606060;"> 43:</span> <span style="color: #0000ff;">HTTP::respond</span> 301 location <span style="color: #006080;">"https://domain.com/$newapp"</span>
<span id="lnum44" style="color: #606060;"> 44:</span>
<span id="lnum45" style="color: #606060;"> 45:</span> } <span style="color: #0000ff;">elseif</span> {$app ne <span style="color: #006080;">""</span> && $newapp_value ne <span style="color: #006080;">""</span>}{
<span id="lnum46" style="color: #606060;"> 46:</span>
<span id="lnum47" style="color: #606060;"> 47:</span> <span style="color: #008000;">## replace with new URI</span>
<span id="lnum48" style="color: #606060;"> 48:</span> <span style="color: #0000ff;">HTTP::uri</span> <span style="color: #006080;">"/newapp$newapp_value?user=$app"</span>
<span id="lnum49" style="color: #606060;"> 49:</span> <span style="color: #0000ff;">log</span> local0. <span style="color: #006080;">"This has been rewritten, and the new URI is [HTTP::uri]"</span>
<span id="lnum50" style="color: #606060;"> 50:</span>
<span id="lnum51" style="color: #606060;"> 51:</span> <span style="color: #008000;">## Save the find/replace strings for responses </span>
<span id="lnum52" style="color: #606060;"> 52:</span> <span style="color: #0000ff;">set</span> internal_uri <span style="color: #006080;">"/newapp$newapp_value?user=$app"</span>
<span id="lnum53" style="color: #606060;"> 53:</span> <span style="color: #0000ff;">set</span> external_uri <span style="color: #006080;">"/$app"</span>
<span id="lnum54" style="color: #606060;"> 54:</span> <span style="color: #0000ff;">log</span> local0. <span style="color: #006080;">" This is the internal URI $internal_uri"</span>
<span id="lnum55" style="color: #606060;"> 55:</span> <span style="color: #0000ff;">log</span> local0. <span style="color: #006080;">"This is the external URI $external_uri"</span>
<span id="lnum56" style="color: #606060;"> 56:</span> }
<span id="lnum57" style="color: #606060;"> 57:</span> <span style="color: #0000ff;">else</span> {
<span id="lnum58" style="color: #606060;"> 58:</span> <span style="color: #008000;">## Do nothing to responses if there wasn't any match</span>
<span id="lnum59" style="color: #606060;"> 59:</span> <span style="color: #0000ff;">set</span> internal_uri <span style="color: #006080;">""</span>
<span id="lnum60" style="color: #606060;"> 60:</span> <span style="color: #0000ff;">log</span> local0. <span style="color: #006080;">"There is no match,we will do nothing"</span>
<span id="lnum61" style="color: #606060;"> 61:</span>
<span id="lnum62" style="color: #606060;"> 62:</span> }
<span id="lnum63" style="color: #606060;"> 63:</span>
<span id="lnum64" style="color: #606060;"> 64:</span> <span style="color: #008000;">## if we're potentially going to rewrite the response headers and/or content</span>
<span id="lnum65" style="color: #606060;"> 65:</span> <span style="color: #008000;">## prevert the server from sending a compressed response</span>
<span id="lnum66" style="color: #606060;"> 66:</span>
<span id="lnum67" style="color: #606060;"> 67:</span> <span style="color: #0000ff;">if</span> {$internal_uri ne <span style="color: #006080;">""</span> && [<span style="color: #0000ff;">HTTP::header</span> exists <span style="color: #006080;">"Accept-Encoding"</span>]}{
<span id="lnum68" style="color: #606060;"> 68:</span> <span style="color: #0000ff;">log</span> local0. <span style="color: #006080;">"This will be rewritten, and we will prevent the server from sending a compressed response"</span>
<span id="lnum69" style="color: #606060;"> 69:</span> <span style="color: #0000ff;">HTTP::header</span> remove Accept-Encoding
<span id="lnum70" style="color: #606060;"> 70:</span> }
<span id="lnum71" style="color: #606060;"> 71:</span>
<span id="lnum72" style="color: #606060;"> 72:</span>
<span id="lnum73" style="color: #606060;"> 73:</span> }
<span id="lnum74" style="color: #606060;"> 74:</span>
<span id="lnum75" style="color: #606060;"> 75:</span>
<span id="lnum76" style="color: #606060;"> 76:</span> <span style="color: #008000;">## Number 3. Any response bound for the user that directs the user to</span>
<span id="lnum77" style="color: #606060;"> 77:</span> <span style="color: #008000;">## domain.com/newapp[1-20]?user= must be re-written to the requesting format</span>
<span id="lnum78" style="color: #606060;"> 78:</span> <span style="color: #008000;">## of domain.com/</span>
<span id="lnum79" style="color: #606060;"> 79:</span> <span style="color: #0000ff;">priority</span> 150
<span id="lnum80" style="color: #606060;"> 80:</span> <span style="color: #0000ff;">when</span> <span style="color: #cc6633;">HTTP_RESPONSE</span> {
<span id="lnum81" style="color: #606060;"> 81:</span>
<span id="lnum82" style="color: #606060;"> 82:</span> <span style="color: #008000;">## Check if we're potentially rewriting this response</span>
<span id="lnum83" style="color: #606060;"> 83:</span> <span style="color: #0000ff;">if</span> {$internal_uri ne <span style="color: #006080;">""</span>}{
<span id="lnum84" style="color: #606060;"> 84:</span> <span style="color: #0000ff;">log</span> local0. <span style="color: #006080;">"There is a value for internal uri which is $internal_uri"</span>
<span id="lnum85" style="color: #606060;"> 85:</span> <span style="color: #008000;">## Rewrite the response content using a stream profile if it is text</span>
<span id="lnum86" style="color: #606060;"> 86:</span> <span style="color: #0000ff;">if</span> {[<span style="color: #0000ff;">HTTP::header</span> Content-Type] <span style="color: #0000ff;">contains</span> <span style="color: #006080;">"text"</span>}{
<span id="lnum87" style="color: #606060;"> 87:</span>
<span id="lnum88" style="color: #606060;"> 88:</span> <span style="color: #008000;">## Set the stream expression with the find/replace strings</span>
<span id="lnum89" style="color: #606060;"> 89:</span> <span style="color: #0000ff;">STREAM::expression</span> <span style="color: #006080;">"@$internal_uri@$external_uri@"</span>
<span id="lnum90" style="color: #606060;"> 90:</span> <span style="color: #0000ff;">log</span> local0. <span style="color: #006080;">"Running a stream, replace $internal_uri with $external_uri"</span>
<span id="lnum91" style="color: #606060;"> 91:</span>
<span id="lnum92" style="color: #606060;"> 92:</span> <span style="color: #008000;">## Enable the stream filter</span>
<span id="lnum93" style="color: #606060;"> 93:</span> <span style="color: #0000ff;">STREAM::enable</span>
<span id="lnum94" style="color: #606060;"> 94:</span> }
<span id="lnum95" style="color: #606060;"> 95:</span> }
<span id="lnum96" style="color: #606060;"> 96:</span> }
Last, but most certainly not least, the Winner of the iRules FSE Challenge - Brandon Frelich!
Brandon’s iRule was the closest out of the bunch on functionality, showed an extremely solid understanding of programming fundamentals with some tricksy logic games that I was shocked to see a newbie playing, reminding me that these people are not at all newbs, just new to F5, and it’s even pretty to look at and easy to follow. Really a phenomenal job and a great effort put in here. If you’re looking to place bets on a hot iRules up and comer, you’ll have to get in line behind me to bet on Brandon.
<span id="lnum1" style="color: #606060;"> 1:</span> <span style="color: #008000;"># Applied to http virtual server VS_domain_com_80 for domain.com</span>
<span id="lnum2" style="color: #606060;"> 2:</span> <span style="color: #0000ff;">when</span> <span style="color: #cc6633;">HTTP_REQUEST</span> {
<span id="lnum3" style="color: #606060;"> 3:</span> <span style="color: #0000ff;">HTTP::respond</span> 301 Location “https:<span style="color: #008000;">//[getfield [HTTP::host] : 1][HTTP::uri]”</span>
<span id="lnum4" style="color: #606060;"> 4:</span> }
<span id="lnum5" style="color: #606060;"> 5:</span>
<span id="lnum6" style="color: #606060;"> 6:</span> <span style="color: #008000;"># Applied to client ssl virtual server VS_domain_com_443 for domain.com:443</span>
<span id="lnum7" style="color: #606060;"> 7:</span> <span style="color: #0000ff;">when</span> <span style="color: #cc6633;">HTTP_REQUEST</span> {
<span id="lnum8" style="color: #606060;"> 8:</span> <span style="color: #0000ff;">HTTP::header</span> remove <span style="color: #006080;">"Accept-Encoding"</span>
<span id="lnum9" style="color: #606060;"> 9:</span> <span style="color: #008000;"># Grab the hostname and uri</span>
<span id="lnum10" style="color: #606060;"> 10:</span> <span style="color: #008000;"># Set a Value to determine if we should do anything with the response</span>
<span id="lnum11" style="color: #606060;"> 11:</span> <span style="color: #0000ff;">set</span> iReWroteThis 0
<span id="lnum12" style="color: #606060;"> 12:</span> <span style="color: #0000ff;">set</span> hostname [<span style="color: #0000ff;">string</span> tolower [<span style="color: #0000ff;">HTTP::host</span>]]
<span id="lnum13" style="color: #606060;"> 13:</span> <span style="color: #0000ff;">set</span> uri [<span style="color: #0000ff;">string</span> tolower [<span style="color: #0000ff;">HTTP::uri</span>]]
<span id="lnum14" style="color: #606060;"> 14:</span> <span style="color: #008000;"># disable stream processing on the request</span>
<span id="lnum15" style="color: #606060;"> 15:</span> <span style="color: #0000ff;">STREAM::disable</span>
<span id="lnum16" style="color: #606060;"> 16:</span> <span style="color: #008000;"># Determine if we should bother to continue processing this request</span>
<span id="lnum17" style="color: #606060;"> 17:</span> <span style="color: #0000ff;">if</span> { ($hostname == <span style="color: #006080;">"domain.com"</span>) } {
<span id="lnum18" style="color: #606060;"> 18:</span> <span style="color: #0000ff;">if</span> { $uri <span style="color: #0000ff;">starts_with</span> <span style="color: #006080;">"/app"</span> } {
<span id="lnum19" style="color: #606060;"> 19:</span> <span style="color: #008000;"># First determine where the uri ends and if there's a query after it</span>
<span id="lnum20" style="color: #606060;"> 20:</span> <span style="color: #0000ff;">if</span> { [<span style="color: #0000ff;">HTTP::query</span>] == <span style="color: #006080;">""</span> } {
<span id="lnum21" style="color: #606060;"> 21:</span> <span style="color: #0000ff;">set</span> a [ <span style="color: #0000ff;">substr</span> $uri 4 <span style="color: #006080;">"?"</span> ]
<span id="lnum22" style="color: #606060;"> 22:</span> }
<span id="lnum23" style="color: #606060;"> 23:</span> <span style="color: #0000ff;">else</span> {
<span id="lnum24" style="color: #606060;"> 24:</span> <span style="color: #008000;"># if there isn't a value for query string we'll take up until / in the uri.</span>
<span id="lnum25" style="color: #606060;"> 25:</span> <span style="color: #0000ff;">set</span> a [<span style="color: #0000ff;">substr</span> $uri 4 <span style="color: #006080;">"/"</span>]
<span id="lnum26" style="color: #606060;"> 26:</span> }
<span id="lnum27" style="color: #606060;"> 27:</span> <span style="color: #008000;"># Ok so we have the characters after. Let's see if they're first a digit</span>
<span id="lnum28" style="color: #606060;"> 28:</span> <span style="color: #008000;"># and then between 1 & 20</span>
<span id="lnum29" style="color: #606060;"> 29:</span> <span style="color: #0000ff;">if</span> { [<span style="color: #0000ff;">string</span> is digit $a] && ($a = 1) } {
<span id="lnum30" style="color: #606060;"> 30:</span> <span style="color: #008000;"># map /app over with /newapp but preserve the rest of the request</span>
<span id="lnum31" style="color: #606060;"> 31:</span> <span style="color: #0000ff;">HTTP::respond</span> 301 Location [<span style="color: #0000ff;">string</span> map {<span style="color: #006080;">"/app"</span> <span style="color: #006080;">"/newapp"</span>} $uri]
<span id="lnum32" style="color: #606060;"> 32:</span> }
<span id="lnum33" style="color: #606060;"> 33:</span> }
<span id="lnum34" style="color: #606060;"> 34:</span> <span style="color: #0000ff;">elseif</span> { [ <span style="color: #0000ff;">class</span> match [<span style="color: #0000ff;">string</span> map { <span style="color: #006080;">"/"</span> <span style="color: #006080;">""</span> } $uri] <span style="color: #0000ff;">equals</span> btcp_red ] } {
<span id="lnum35" style="color: #606060;"> 35:</span> <span style="color: #0000ff;">set</span> number [ <span style="color: #0000ff;">class</span> match -value [<span style="color: #0000ff;">string</span> map { <span style="color: #006080;">"/"</span> <span style="color: #006080;">""</span> } $uri] <span style="color: #0000ff;">equals</span> btcp_red ]
<span id="lnum36" style="color: #606060;"> 36:</span> <span style="color: #0000ff;">set</span> name [ <span style="color: #0000ff;">class</span> match -name [<span style="color: #0000ff;">string</span> map { <span style="color: #006080;">"/"</span> <span style="color: #006080;">""</span> } $uri] <span style="color: #0000ff;">equals</span> btcp_red ]
<span id="lnum37" style="color: #606060;"> 37:</span> <span style="color: #0000ff;">set</span> newquery <span style="color: #006080;">"\?user=$name"</span>
<span id="lnum38" style="color: #606060;"> 38:</span> <span style="color: #0000ff;">set</span> newuri <span style="color: #006080;">"/newapp$number$newquery"</span>
<span id="lnum39" style="color: #606060;"> 39:</span> <span style="color: #0000ff;">HTTP::uri</span> $newuri
<span id="lnum40" style="color: #606060;"> 40:</span> <span style="color: #0000ff;">set</span> iReWroteThis 1
<span id="lnum41" style="color: #606060;"> 41:</span> <span style="color: #008000;">#debug use log local0. "uri is now $uri and name $name and number $number and newuri $newuri$newquery"</span>
<span id="lnum42" style="color: #606060;"> 42:</span> }
<span id="lnum43" style="color: #606060;"> 43:</span> <span style="color: #0000ff;">else</span> {
<span id="lnum44" style="color: #606060;"> 44:</span> <span style="color: #008000;"># debug use log local0. "Well we didn't match anything uri is $uri"</span>
<span id="lnum45" style="color: #606060;"> 45:</span> }
<span id="lnum46" style="color: #606060;"> 46:</span> }
<span id="lnum47" style="color: #606060;"> 47:</span> }
<span id="lnum48" style="color: #606060;"> 48:</span> <span style="color: #0000ff;">when</span> <span style="color: #cc6633;">HTTP_RESPONSE</span> {
<span id="lnum49" style="color: #606060;"> 49:</span> <span style="color: #008000;"># Did we rewrite the request?</span>
<span id="lnum50" style="color: #606060;"> 50:</span> <span style="color: #0000ff;">if</span> { $iReWroteThis } {
<span id="lnum51" style="color: #606060;"> 51:</span> <span style="color: #008000;"># Ok so use the previously stored value to overwrite any reference to domain.com/newapp20?user=bob -> domain.com/bob</span>
<span id="lnum52" style="color: #606060;"> 52:</span> <span style="color: #0000ff;">STREAM::expression</span> <span style="color: #006080;">"@$newuri@$uri@"</span>
<span id="lnum53" style="color: #606060;"> 53:</span> <span style="color: #0000ff;">STREAM::enable</span>
<span id="lnum54" style="color: #606060;"> 54:</span> }
<span id="lnum55" style="color: #606060;"> 55:</span> }
All in all it was a great experience, as always, and the engineers that stepped up to the challenge did an exemplary job. I’m excited for the future of the field if this is the caliber of people we’re bringing on. Way to go to all of the participants, and to anyone joining the team in the mean time…your time is coming, I’ll see you soon.