BIG-IP 9.1.0 Build 6.2 IRULE ** Newbie**

I’ve inherited this wonderful device and now need to learn how to write an irule.

Objective:

What I would like to do is match on a URL and send requests for certain portions of pages to a new server(via IP address).

For example, any request coming in for

http://www.domainname.com/cached/\* or

http://www.domainname.com/assets/\* or

http://www.domainname.com/art/\*

is then sent to a specific destination server.

Any assistance would be very helpful

Thanks!

My first attempt at this:

when HTTP_REQUEST {

if { [HTTP::uri] ends_with “cached” } {

pool NSF

} elseif { [HTTP::uri] ends_with “assests” } {

pool NSF

} elseif { [HTTP::uri] ends_with “art” } {

pool NSF

}

}

Will this work for what I want?

That should work fine. If your list grows beyond 3 URLS, you will probably want to look at the matchclass functions (see the wiki) so that you can do one comparison against a list instead of a comparison for each possibility.

Also your current rule will “fall out” to the default pool defined in the virtual without a match, if you want to be more specific about that you can end with an “else” and direct that to the default pool.

Denny

EDIT: See this post Click here for more information about default pool selection…it is usually better to explicitly define it.

Denny

Denny,

Thanks for the reply. The next question is how do we keep the persistence for the sessions. Here is what another tech said in regards to this.

The problem with that is the persistence that is enabled. When using that rule, any connection that makes a request to /cached/, /art/, or /assets/ will have its entire connection moved over to the NFS server, which is invalid. I was trying to find a way to disable persistence for individual requests in hopes of being able to disable persistence, send the request to the NFS server and then re-enable persistence.

Is this possible?

Further clarification on the above is that the code will drop you to the new server (NFS) or the NFS pool but then we need to be able to traverse back to the default web pool. How do I add at the end of the code that the following request after it gets what is needed from the NFS pool to go back to the web pool?

Hi Matt -

This rule does the same thing as the if/else version, and adds a default pool selection for any non-matching request:

when HTTP_REQUEST {
  switch -glob [HTTP::uri] {
    *cached -
    *assets -
    *art {pool NSF}
    default {pool web}
  }
}

You’ll also need to apply a OneConnect profile to ensure that multiple requests on the same connections are not routed to the first pool chosen for that connection.

HTH

/deb

Deb,

Thanks for the post but I’m not sure I follow the OneConnect profile. How does this work?

I’ve looked at implementing the OneConnect profile and it appears to be out of my league. Looking at the ONECONNECT::detach [enable | disable ]

I suppose when I meet the criteria in the above code I want to detach

when HTTP_REQUEST {

switch -glob [HTTP::uri] { ONECONNECT::detach enable

*cached -

*assets -

*art {pool NSF}

default {pool web}

}

}

My question is do I need to add a ONECONNECT::reuse enable?

Will the above code work? I’m trying to test this and it appears to still be using the NFS pool.

Oh, sorry for the confusion. I should have been clearer.

You can either create a custom oneconnect profile (Virtual Servers / Profiles / Other / OneConnect) or apply the default oneconnect profile to the virtual server itself by selecting the desired profile for the “OneConnect Profile” setting. The profile will then apply to all connections passing through it. Leave “OneConnect Transformations” enabled in the applied http profile. (It is enabled by default.)

If you want instead to go the detach route, the command you want is actually “LB::detach”, and you’d put it immediately above the pool command. But using the profile as described above is simpler & more efficient, so I’d go that route.

HTH

/deb

I just got the lowdown on the ONECONNECT commands commands from Product Development.

They give us finer-grained control the behaviour of OneConnect when it’s enabled, but that’s not what you need.

I will be updating the wiki shortly with that info -- thanks for the reminder!

/deb

Deb,

You rock! I should be able to drive from here!

Thanks again…