Forum Discussion

Kareem's avatar
Kareem
Icon for Nimbostratus rankNimbostratus
Dec 09, 2014

Can't save an iRule because of formatting issues.

Hi,

 

I am having trouble formatting this irule:

 

when CLIENT_ACCEPTED { if { [class match [IP::remote_addr] equals O365_Microsoft_Networks_dg] } { if {([HTTP::uri] contains “/ews”)} { pool O365_POC_Exchange_owa_pool7 } }

 

Can someone help as soon as possible please ?

 

5 Replies

  • Kareem's avatar
    Kareem
    Icon for Nimbostratus rankNimbostratus
    01070151:3: Rule [/Common/O365_Microsoft_Networks_dg_irule] error: /Common/O365_Microsoft_Networks_dg_irule:1: error: [parse error: missing close-brace][{ if { [class match [IP::remote_addr] equals O365_Microsoft_Networks_dg] } { if {([HTTP::uri] contains &8220;/ews&8221;)} { pool O365_POC_Exchange_owa_pool7 } }] /Common/O365_Microsoft_Networks_dg_irule:2: error: [command is not valid in the current scope][if { [class match [IP::remote_addr] equals O365_Microsoft_Networks_dg] } { if {([HTTP::uri] contains &8220;/ews&8221;)} { pool O365_POC_Exchange_owa_pool7 } }]
  • you cannot use HTTP:: command in CLIENT_ACCEPTED. change to HTTP_REQUEST event and it looks okay here.

    root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux
    ltm rule qux {
        when HTTP_REQUEST {
      if { [class match [IP::remote_addr] equals O365_Microsoft_Networks_dg] } {
        if { ([HTTP::uri] contains "/ews")} {
          pool O365_POC_Exchange_owa_pool7
        }
      }
    }
    }
    
  • Kareem's avatar
    Kareem
    Icon for Nimbostratus rankNimbostratus

    Thanks, that works. What if I want two conditions to be met before the pool is chosen, what should the irule look like ? Below is the current irule: I mean make it only one if statement:

     

    when HTTP_REQUEST { if {[class match [IP::remote_addr] equals O365_Microsoft_Networks_dg]} {

     

    if {[HTTP::path] equals "/ews" } { pool O365_POC_Exchange_owa_pool7 } } }

     

  • What if I want two conditions to be met before the pool is chosen, what should the irule look like ?

    you can use operator such as and, or.

    if { condition1 and condition2 } {
       action
    }
    
  • can you try this?

    when HTTP_REQUEST { 
       if { [class match [IP::remote_addr] equals O365_Microsoft_Networks_dg] and [HTTP::path] equals "/ews" } { 
          pool O365_POC_Exchange_owa_pool7 
       } 
    }