Forum Discussion

wlepkin_98758's avatar
wlepkin_98758
Icon for Nimbostratus rankNimbostratus
Dec 29, 2011

F5 does not accept iRule

Hi, I'm new at iRules, and am having trouble with what seems to be a pretty basic rule, modeled after other rules I've seen both in our BigIP configuration and in DevCentral. The rule is:

 

 

rule myapps.jeppesen.com-citrixtest {

 

when HTTP_REQUEST {

 

if { [HTTP::header User-Agent] contains "CitrixReceiver" } then {

 

HTTP::redirect "https://myapps/PNAgent/config.xml"

 

} else {

 

HTTP::redirect "https://myapps/Citrix/XenApp"

 

}

 

}

 

}

 

 

I'm running BIG-IP version 9.4.6, and when I try to enter the rule via the command line, one line at a time, it likes the first and second lines, but when I enter the 'if' clause line (3rd line) I get the following error message:

 

 

BIGpipe parsing error: 012e0021:3: The requested attribute (if {) for 'rule' is invalid.

 

 

I've tried all different combinations of spacing, placement of braces, leaving out the 'then' and 'else', using 'string tolower', but every time it chokes on the 'if' clause. The rule is very similar to a rule I've seen discussed in DevCentral, with the addition of the 'else' clause. The problem must be something simple, but I just can't see it.

 

 

Anyone have any ideas?

 

 

Thanks much.

 

  • can you try this?

    [root@ve1023:Active] config  b rule myapps.jeppesen.com-citrixtest '{
    >  when HTTP_REQUEST {
    >  if { [HTTP::header User-Agent] contains "CitrixReceiver" } then {
    >    HTTP::redirect "https://myapps/PNAgent/config.xml"
    >  } else {
    >    HTTP::redirect "https://myapps/Citrix/XenApp"
    >  }
    >  }
    >  }'
    [root@ve1023:Active] config  b rule myapps.jeppesen.com-citrixtest list
    rule myapps.jeppesen.com-citrixtest {
       when HTTP_REQUEST {
     if { [HTTP::header User-Agent] contains "CitrixReceiver" } then {
       HTTP::redirect "https://myapps/PNAgent/config.xml"
     } else {
       HTTP::redirect "https://myapps/Citrix/XenApp"
     }
     }
    }
    
  • Can you try it without the "then":

    
    when HTTP_REQUEST {
    if { [HTTP::header User-Agent] contains "CitrixReceiver" } {
    HTTP::redirect "https://myapps/PNAgent/config.xml"
    } else {
    HTTP::redirect "https://myapps/Citrix/XenApp"
    }
    }
    

    Aaron
  • Wow, that worked! I assume the 'b' is an abbreviation for 'bigpipe', and thus apparently the problem was not with the rule itself, but rather just the way I was entering it.

     

     

    I've used the bigpipe command with another F5 that has an older code version that does not have the bp shell. But with this F5, that does have the bp shell, I have had success going into the shell and just entering commands, as I tried to do in this case. So there must be something different about an iRule (or about this iRule) that caused the problem.

     

     

    Thanks!

     

     

  • Um, sorry, am not familiar with the forum, and had assumed that my reply above would be associated with the particular answer I replied to. 'nitass's suggestion was what did the trick, and I thank him. With respect to 'hoolio's suggestion, I had already tried eliminating the 'then', which made no difference, but thanks anyway.

     

     

  • No worries...

     

     

    If you're defining the iRule from the bash command line on v9 or v10, you can use b or bigpipe. 'b' is a symbolic link to bigpipe:

     

     

    file /usr/bin/b

     

    /usr/bin/b: symbolic link to `bigpipe'

     

     

     

    When using bigpipe, make sure to escape new lines in the iRule by wrapping the outer curly braces in single quotes like Nitass did.

     

     

    b rule myapps.jeppesen.com-citrixtest '{

     

    when HTTP_REQUEST {

     

    if { [HTTP::header User-Agent] contains "CitrixReceiver" } then {

     

    HTTP::redirect "https://myapps/PNAgent/config.xml"

     

    } else {

     

    HTTP::redirect "https://myapps/Citrix/XenApp"

     

    }

     

    }

     

    }'

     

     

    If you're adding the iRule in the GUI or iRule Editor, leave out "rule rule_name" and outer curly braces. The GUI and iRule Editor add this for you. Most of the examples on DC assume you're using the GUI or iRule Editor.

     

     

    I've never used bpsh to create new objects, so I'm not sure why it wouldn't have worked with that. bpsh and bigpipe have been removed from the BIG-IP in v11. So I'd start focusing on using tmsh for command line tasks:

     

     

    http://devcentral.f5.com/wiki/TMSH.HomePage.ashx

     

     

    Aaron