Forum Discussion

andy_22730's avatar
andy_22730
Icon for Nimbostratus rankNimbostratus
Apr 10, 2007

Need IRule to forward urls to different VIPs

Hello:

 

 

I'm just starting out w/ iRules and our new BigIP 6800s.

 

 

I have a basic web-app setup: VIPS for http, https that forward to a Pool of linux hosts with Tomcat for our we app.

 

 

What I need is an iRule to take any incoming request that contains a reference to our static images (/images) and re-direct that to a different pool, one which has apache http to serve this static content. Having tomcat serve this static content is too slow.

 

 

But I need this to work in a way that is transparent to the tomcat application.

 

 

Can the F5 and some iRules accomplish this?

 

 

Any pointers on how I would start to build such a rule?

 

 

3 Replies

  • This iRule will work (assuming you are terminating the ssl connection on the BIG-IP - if not, then there is no way to inspect the payload).

    when HTTP_REQUEST {
      if { [HTTP::uri] starts_with "/images" } {
        pool insert_image_pool_name_here
      }
    }

    Just change "insert_image_pool_name_here" with the name of you pool containing the image servers and you should be set.

    The above example will just direct the content at the different pool. If you truely want to do a HTTP redirect, then you'll have to have another virtual setup using the image pool and use the HTTP::redirect command to send the redirect directive back to the browser.

    -Joe
  • Ok, first- thanks for the quick response.

     

     

    Yes, I'm terminating the SSL on the Big IP, so I expect to be able to inspect all packets.

     

     

    I see what you mean- this seems to be only the 1st half of the problem.

     

     

    Once I've redirected these requests to the new pool, I'm a bit confused as to what is next. You seem to be saying that a redirect iRule is also necessary to re-direct back the response from my "static image pool" back to the original requester. And if this is the case, I must again ask for help in constructing a proper iRule to do this.

     

     

    I'm not 100% on what is required- does the BigIP know how to send the result back properly?

     

     

    thanks again,

     

     

    andy
  • From what you stated in your original question, a full redirect is probably not needed. I just put it in there because you mentioned you wanted to redirect to a different pool.

     

     

    If all you want to do is have traffic directed at /images* to go to a non-default pool, then the code sample I provided is all you'll need. The "pool" command tells the routing components to send the traffic to a server in that pool. The URI will remain the same, just the destination server will change from the default pool of servers, to the one you specified.

     

     

    -Joe