Forum Discussion

Ian_105608's avatar
Ian_105608
Icon for Nimbostratus rankNimbostratus
Feb 03, 2010

Customer Defined Functions

Gday,

 

 

We are using HTTP::path to do HTTP routing decisions. We have some fairly long irules that have many applications on a virtual server pointing to several different servers.

 

 

One thing we'd like to do is emulate Apache named virtual hosting in an iRule. The thing holding us back is we'd end up with mass nested difficult to read irules like :

 

 

when HTTP_REQUEST {

 

if { [HTTP::host] equals "site" } {

 

if { [HTTP::path] starts_with "/" } {

 

pool blah

 

}

 

}

 

}

 

 

Ad naseum for multiple hosts / paths. What I'd like to do is change the nested if to call another irule that contains the path decision.

 

 

So something like :

 

 

when HTTP_REQUEST {

 

if { [HTTP::host] equals "site" } {

 

call somesite_directory(request_object);

 

}

 

}

 

 

Did a bit of googling but couldn't find anything.

 

 

Any ideas?

 

 

Cheers,

 

Ian

 

1 Reply

  • Hi Ian,

     

     

    There has been discussion here about supporting user defined functions. Last I read they're still under consideration.

     

     

    However, for your scenario, I think using a datagroup mapping the host, paths and pool would be more efficient (and possible in current versions). If you're on v10, you can use the new class command (Click here). For 9.x, you can use the findclass or TCL list commands to look up the corresponding pool.

     

     

    For examples, you can check the wiki pages or search the iRules forums for findclass, "http::host", class, etc.

     

     

    Another option would be to use the ProxyPassV9 or ProxyPassV10 iRules to do this:

     

     

    iRule codeshare (Click here)

     

     

    Aaron