The F5 BIG-IP iRules redirection Generator.

New iRules users are often floored by the sheer volume of possibilities they are confronted with. iRules offers you amazing flexibility in solving your networking problems with ingenious solutions, but as with everything that flexibility comes at the expense of ease-of-use. The iRules Editor, its tutorials and samples along with the iRules Wiki and the DevCentral iRules articles, offer a ton of information to get you started and expand your knowledge all the way to the expert level.

But what if you are faced with a simple problem today and don't have time to absorb all of that information before finding a solution? In the spirit of the iControl to Implementation (iC2I) series of articles, we offer the iRule Redirection Generator.

This simple program merely generates the iRules for the most common redirection problems that DevCentral readers run into. If you just need to quickly generate an iRule to deal with redirection to URI, Pool, or HTTPS to HTTP, this is the program for you. If you want to learn a bit more about iRules and a tiny bit about iControl (there are two iControl calls in this program as originally released), this is also the program for you.

If you are already an iRules guru, this program might be mildly interesting to you, but only from a curiosity perspective. There's nothing astounding here, just straight-forward application of iRules to solve redirection problems. Great for learning, probably not the first thing you will pull up if you know how to do redirection already.

The tabs and how to use them.

Route By URI
When the program loads, you are presented with the "Route By URI" tab. This tab allows you to map from an incoming URI to an outgoing URI. Fill in the URI you want to redirect in the "When this URI is received" field, and fill in the URI you want to actually send the request to in the "Route to URI" field, then click the Generate button. The text box will fill with a complete iRUle for redirecting the incoming URI to the Route To URI. The text box is fully edit/copy/paste enabled, so you can modify the resulting rule, select the bits you need and paste them into your existing iRules.

Route By Pool

When you want to send all requests for a given URI to a particular Pool - say you have two domains sharing a public IP address and you want to route traffic correctly - then use this tab. Since the pool must exist on the BIG-IP you are going to put the rule on, you have to click "Log in to a BIG-IP" and enter the BIG-IP address or FQDN and your credentials on that device. Once the login dialog has been filled out and Okay clicked, the list of Pools on the BIG-IP will be downloaded and the Route to Pool list filled with those pool names. Then fill in the "When this URI is received" field and select a pool from the "Route to Pool" list, and click the Generate button. Again, this text box is fully enabled, so you can modify the resulting rule snippet and paste it into any iRule.

HTTP to HTTPS redirect

This is a simple set of rules that will redirect incoming HTTPS connections to HTTP - effectively terminating HTTPS for you and allowing communications behind the BIG-IP to occur over HTTP. These samples are taken directly from the iRUles Wiki page on Redirects using status 301 "moved permanently" codes. These redirects just respond to the browser that the page has moved and gives it the new HTTPS location at which the file can be found. Since these assume the same server, no variable data needs to be selected, just select the one that is best for your needs - remembering that each connection must execute each line of these scripts, so use the simple one if possible, the "Port 80 only" one if Virtual Servers are attached, and the "Port 80 with Server Sub" option if you might receive hosts that do not fill in the Host field of the HTTP header. Then click the "Generate" button, and the necessary iRule will end up in the edit window. Modify it as needed and cut/paste it into your iRules.

About and Usage.

Describes how to use the program (by including this document, actually), and credits F5 Networks. All pretty easy stuff.This application is a good platform from which to build other simple iRules generators for other common problems... Watch the Docs section on DevCentral for future updates. As a Labs project, we do intend to improve the tool as time goes on.

 

Summary

It's pretty easy to create quick little applications that generate iRules that are useful for your environment. Based upon the iControl Assembly for C#, this applicaiton also provides an example of one way to get your applications to use iControl calls.

 

 Where to get it?

Download the application as a Windows executable or download the entire source project in the Labs section under iRule Redirection Generator