Direct Access irule problem...

Hello,

I have built (copied) the following irule and am having trouble making it do what i want… I want a url like http://view.usg.edu/dvw5 to go directly to the web root on the machine named dvw5 (or http://10.1.1.5/ in the class below).

here’s the class:

class db300_direct {

dvw5 10.1.1.5:8000

dvw6 10.1.1.6:8000

}

and here’s the irule:

when HTTP_REQUEST {

if { [HTTP::uri] starts_with “/dv” } {

set urimbr [substr [HTTP::uri] 1 “/”]

log local0. $urimbr

set node [findclass $urimbr $::db300_direct " "]

log local0. $node

pool VistaWebApps member $node

}

}

Now according to my log, $urimbr is what i expect, and $node is what i expect. I get a 404 error from the machine. When i captured the packets and looked at the trace, i see that the packet is in fact getting directed to the $node as i expect, but the thing i don’t understand, (and haven’t been able to figure out with much trial and error) is that it is being directed to http://10.1.1.5/dvw5 and since there is no directory dvw5 under the web root, the 404 error is understandable.

The thing is, i don’t want the request to go to http://10.1.1.5/dvw5 -- i want it to go to http://10.1.1.5/

If someone would be so kind as to help me understand what i am doing wrong i would be most gratefull.

Thanks in advance!

Morning sspencer,

It looks to me as though the issue is the fact that you’re passing the full, initial request to the selected node, instead of changing the destination address.

When you use the pool command to decide where the request will be sent, it takes the original request (including the full URI) and sends it to that pool (or node). This is why the “/dvw5” is being carried over, and as a result, it’s why you’re seeing the 404 Error.

So to remedy this, you would want to change:

pool VistaWebApps member $node

To be something like:

[HTTP::redirect $node]

This would change the intended destination, and as such should remove the URI from the request. This is a full HTTP redirect, rather than just a load balancing decision, so you should get the desired result of seeing the request go to just the IP of the intended node.

Give it a try and let me know if you have any questions.

-Colin

Alternatively, you could rewrite the request without redirecting.

Click here to see this related post:

http://devcentral.f5.com/default.aspx?tabid=28&view=topic&forumid=5&postid=3269