Forum Discussion

jcoleman_105753's avatar
jcoleman_105753
Historic F5 Account
Nov 20, 2007

Virtual Entry in iRules Wiki

The iRules wiki has the following sample code that is suppose to allow you to "Route the traffic to virtual server instead of normal server selection by load balancing." However, in 9.4.3 and in 9.2.4 entering the code below taken verbatim from the wiki results in this error, 01070151:3: Rule [test] error:line 2: [invalid keyword "my_post_processing_server" must be: name] [my_post_processing_server]". Is there syntax missing?

 

 

when HTTP_REQUEST {

 

virtual my_post_processing_server

 

}

 

 

Maybe this is not what I am looking for I want to redirect a client to another virtual server based upon criteria that I specify; for instance a specific string in the uri. Based on the info from the site I created the following iRule.

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] contains "/training" } {

 

virtual media_80

 

}

 

}

 

 

Is there a different or more correct way of doing this.

 

 

Thanks for the assist!

2 Replies

  • Hi,

     

     

    In versions before 9.4.0, the command 'virtual' would return the name of the virtual server the rule was applied to. In 9.4.0 and later, you'd have to use 'virtual name' to get the name. Also, in 9.4.0 and later, using the virtual command, you could assign one virtual server as the destination for another virtual server. The rules you listed should work find on 9.4.0 and later assuming 'my_post_processing_server' and 'media_80' are both names of virtual servers.

     

     

    I'd expect the error you posted on 9.2.4. What was the error you saw on 9.4.3? If you use 'virtual NON_EXISTENT_VIP_NAME' you should see:

     

     

    [can't find virtual] [virtual NON_EXISTENT_VIP_NAME]

     

     

    Otherwise, it should work on 9.4.x.

     

     

    Another option would be to send a 30x redirect using HTTP::redirect to the other virtual server.

     

     

    Aaron

     

     

    [edit: I updated the wiki page (Click here) to hopefully make this more clear.]
  • jcoleman_105753's avatar
    jcoleman_105753
    Historic F5 Account
    Aaron,

     

     

    You were absolutely correct I wasn't paying attention and the error I was receiving in 9.4.x was related to an undefined virtual server. When I placed the correct VS name in the rule it accepted it without error.

     

     

    Thanks for the assist.

     

     

    Jason