views:

261

answers:

1

I'm trying to come up with a rule on our F5 to direct traffic to our Tomcat server appropriately. We are deploying separate WAR files for each RESTful service. So, we would like to have the following URIs as an example:

/services/quiz/01234/ /services/user/54321/

Where 'quiz' and 'user' are quiz.war and user.war respectively. We want to direct the traffic at the F5 level for /services/ to be the root and the rest of the URI to be directed to the Tomcat server.

How do we accomplish this?


Edit

The browser url for a resource would look like http://www.domain.com/services/quiz/01234/

I want BIG-IP to send the request to tomcat as http://tomcatserver:8080/quiz/01234/

so basically remove /services and append everything after it to the tomcat domain. I would think this would be an easy regex, right?

+1  A: 

I'm a little rusty on my iRules, but I think that something along these lines will work:

when HTTP_REQUEST {
  set path [HTTP::path]
  regsub "^/services/" $path "/" path
  HTTP::path $path
}

Note that a request for "/services" (without a trailing slash) will get passed through as-is, while a request for "/services/" (with trailing slash but no application) will go to the root application. I wasn't sure how to handle these degenerate cases; you may want to alter this behavior.

By the way, DevCentral has a great community dedicated to helping folks with iRules like these.

erickson
This is a great start. Thanks for your help, I will look into DevCentral as well.
Kyle Hayes