Quantcast



Docs


Blogs


Forums


Samples


Media


Labs


Resources

 




DevCentral > Weblogs > Lori MacVittie - Two Different Socks
 iRules: Ask and ye shall receive
posted on Friday, January 11, 2008 1:42 PM

Erik Dafforn recently posted his Webmaster Wish List for 2008. What it sounds like is that Erik is really asking for tools that make it easier to configure web sites and, more specifically, how web servers respond to requests. What's interesting about his list is that most of his wish list can easily be answered with the implementation of a simple iRule on BIG-IP Local Traffic Manager.

For example, you might have pages such as www.companyname.com/products/ and www.companyname.com/products/index.aspx. Typically, these URLs contain exactly the same content, but due to inconsistent linking throughout the site (and from third-party sites), both URLs become independently indexed and attain independent link popularity values.

Engines are getting better at understanding that URLs like these are frequently, and inadvertently, identical. But great tool would be some logic in the equation, so Webmasters could tell engines, "If a given page '/index.aspx' exists, the page is identical to the URL of the immediately preceding folder, and it should be treated as such."

The good news is that this type of URL manipulation and mapping is a breeze using iRules. The beauty of using iRules as opposed to a tool that would change the configuration of the web server is that once the iRule is written it can be (1) reused and (2) applied to all instances of the appropriate web server, including new ones that might be added later on to address growing capacity needs.

A second item on Erik's wish list is:

a tool that enables Webmasters to assign redirects (either temporary or permanent) from one URL to another

Now I'm not dissing redirects, but there's an even better way to handle this desire. An iRule can easily "map" one URL to another without requiring the additional network traffic and requests incurred by a traditional HTTP redirect. In fact, here's a great little post on the subject from Joe describing the iRule to do this. But in case you really want to redirect, yup - you guessed it - iRules can accomplish that as well. The beauty of using the iRule to do this is that you can eliminate the overhead associated with a redirect. Additionally, a single iRule can be applied to entire farms (pools, clusters) of servers without requiring changes to every web server.

Erik, your wishes are iRules commands. Literally.




Email This
  del.icio.us
      

Feedback


1/11/2008 5:17 PM
Gravatar Lori, I know that iRules are da-bomb. And seeing how they can handle cookies so well, I was really craving a chocolate chip peanut butter since I started my diet this year. In other words, how can iRules help me break my new years resolutions?

-Joe
Joe Pruitt

1/17/2008 10:25 AM
Gravatar I'm brand new to F5 and I'm looking for urgent advice on load balancing - potentially using Irules but am open to suggestions.
I need to impliment a "Site is down for maintenence" redirect that auto kicks in if all servers are unavailble.

Basically we have a simple setup - if a marker file is x, server is up and availble to accept traffic. If a marker file is y, server is down, stop directing traffic to that server.

The basics of what I need to add are "if no server is marked x, redirect to \\ipaddress\site\domain.com - note this down site is on one of the same servers.
Jason Cleland

1/17/2008 11:40 AM
Gravatar Setup a health monitor looking for their "marker" files (I'm assuming he meant a marker file on the server itself). Then the servers will be enabled/disabled depending on the content of that file. You can then check for the active_members in the pool and issue a redirect if the count is 0.

This should do the trick...

when HTTP_REQUEST {
if { [active members [LB::server pool]] == 0 } {
HTTP::redirect http://someserver.com/somepage.html
}
}

-Joe
Joe Pruitt

1/17/2008 4:07 PM
Gravatar Actually, you shouldn't need an iRule for that. You can specify a full URL as the Fallback Host in the http profile.

Be careful of defining the fallback host on the same servers, though, or your users will never get to it if all pool members are down.

/deb
deb

6/24/2008 5:50 PM
Gravatar New F5 user (1 week) using 2 x 6400 LTM's in HA config...

Need a way to redirect URL's from one web site to another both sitting behind the same LTM

e.g. http://123.com/News/tabid/183/Default.aspx redirecting to http://456.com//News/tabid/183/Default.aspx

No idea on how to write / implement irules - training pending

Are irules the only way to do this sort of thing or is there an easier GUI based option?

Graham

6/25/2008 9:54 AM
Gravatar Colin and Deb to the rescue again!

when HTTP_REQUEST {
if { [HTTP::host] ends_with "123.com" } {
HTTP::redirect "http://456.com[HTTP::uri]"
} else {
pool web_pool
}
}

For quick and easy generation of redirection/rewriting iRules, try Don's iRule Redirection Utility
http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=233

Lori
Lori MacVittie
 Leave Feedback
Title  
Name  
Email
Url
Comments   
Please add 8 and 4 and type the answer here: