Forum Discussion

Chris_Stamm_183's avatar
Chris_Stamm_183
Icon for Nimbostratus rankNimbostratus
Nov 03, 2010

http class profile and trailing /

I have one VIP. DNS would resolve this VIP as such. 10.1.1.1 = www.abc.com

 

VIP: 10.1.1.1:80

 

 

To keep it simple let's say I have three http class profiles configured below.

 

 

Httpclass1

 

Look for host name regex string (?i)www.abc.com

 

Look for URI regex string (?i)uri1

 

If both are matched then send to Pool1

 

 

Httpclass2 Look for host name regex string (?i)www.abc.com

 

Look for URI regex string (?i)uri2

 

If both are matched then send to Pool2

 

 

Httpclass3

 

Look for host name regex string (?i)www.abc.com

 

If matched then send to Pool3

 

 

The idea is that if a person types www.abc.com/uri1 (or other variations www.abc.com/uri1/ www.abc.com/uri1/test.html etc.) they are sent to Pool1. If they send www.abc.com/uri2 they are sent to Pool2. The last http class (httpclass3) is a catch all for the domain www.abc.com. I am matching host because eventually there will be more than one host so I would want to be able to match host and URI then make the decision.

 

 

So - the problem is that the user has to type a trailing slash www.abc.com/uri1/ or www.abc.com/uri2/ otherwise it will not catch the string. If the user just types www.abc.com/uri1 or www.abc.com/uri2 then it misses the catch with httpclass1 and httpclass2 so it sends to the catch all http class (httpclass3) and the desired effect is lost.

 

 

Am I doing something wrong in my URI match in the http class?

 

 

I have tried all of the following...

 

/uri1 (pattern string)

 

/uri1* (pattern string)

 

uri1 (pattern string)

 

uri1* (pattern string)

 

(?1)/uri1 (regex)

 

(?1)/uri1* (regex)

 

(?1)uri1* (regex)

 

 

and none seem to work it always requires the trailing /

 

 

6 Replies

  • Chris: for this particular task I'd actually suggest going the iRule route. Do a search on uri switching and you'll see a bunch of examples. I'd suggest using the switch -glob command for this as well. Have a look here for the general idea (look at the second example on URI switching):

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/switch.html

     

     

    -Matt
  • Is it more efficient?

     

     

    After days of searching for answers I just barely came accross this post and created an http profile with matching enabled on the redirect rewrite and that fixed the problem.

     

     

    http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/afv/topic/aft/32808/aff/5/showtab/groupforums/Default.aspx

     

     

    I am going to read up on the redirect rewrite and learn more about it to make sure it does not have any other adverse affects.
  • Hi Chris,

     

     

    Nice work. If rewrite redirects solves the issue, it would be a lot more efficient than coming up with complicated regexes for your HTTP class filters.

     

     

    Aaron
  • With that part working I have another related issue that surfaced. Because we redirect to a different pool on the backend based on the URI that particular URI is sent back unaltered to the backend server - for example...

     

     

    http://www.abc.com/ur1/default.html is sent to a backend pool member as http://10.2.2.1/uri1/default.html

     

     

    If the base path of the webserver is / then I would need a directory in there called uri1 where i placed all the files (i.e. /uri1/default.html, /uri1/whatever.html)

     

     

    In the http class there is a rewrite URI option but I cannot find any documentation on stripping off the /uri1 so the path to the backend server would be http://10.2.2.1/default.html (ideal) as opposed to http://10.2.2.1/uri1/default.html (not ideal).

     

     

    Any ideas where I can find this documentation?

     

     

  • You can use standard TCL commands in the rewrite field:

     

     

    [string map {/uri1/ /} [HTTP::uri]]

     

     

    For more info see SOL7771:

     

     

    SOL7771: Rewriting URIs using the HTTP class profile

     

    http://support.f5.com/kb/en-us/solutions/public/7000/700/sol7771.html

     

     

    Aaron