For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Angelo's avatar
Angelo
Icon for Nimbostratus rankNimbostratus
Jul 13, 2012

I-rule not working

Hi Guys i have a irule but I'm not sure if it is work it's to send three URL to three different pools. I'm not getting errors on the i-rule but I'm not getting out to the pool members when connect. this is what i have...

 

 

when HTTP_REQUEST {

 

switch -glob [string tolower [HTTP::uri]] {

 

"URI 1" {

 

pool pool1

 

}

 

"URI 2" {

 

pool pool2

 

}

 

"URI 3" {

 

pool pool3

 

}

 

 

 

 

 

 

 

 

8 Replies

  • can you put some logging?

    e.g.

    [root@ve10:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
       switch -glob [string tolower [HTTP::uri]] {
          "URI 1" { pool pool1 }
          "URI 2" { pool pool2 }
          "URI 3" { pool pool3 }
            }
    }
    when HTTP_RESPONSE {
       log local0. "[IP::client_addr]:[TCP::client_port] -> [clientside {IP::local_addr}]:[clientside {TCP::local_port}] -> [IP::remote_addr]:[TCP::remote_port]"
    }
    }
    
  • Angelo's avatar
    Angelo
    Icon for Nimbostratus rankNimbostratus
    @nitass

     

     

    Thanks for the reply

     

     

    when trying to add i get a error

     

    line 6: [command is not valid in the current scope] [when HTTP_RESPONSE

     

     

    but another thing even the vendor irules that they installed doesn't seem to work. i can see on the F5 web-front that rules are executed without a error but it's just not working...
  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus
    Angelo

     

     

    Think there's a rogue } at the end. Try this:

     

     

    when HTTP_REQUEST {

     

    switch -glob [string tolower [HTTP::uri]] {

     

    "URI 1" { pool pool1 }

     

    "URI 2" { pool pool2 }

     

    "URI 3" { pool pool3 }

     

    }

     

    }

     

    when HTTP_RESPONSE {

     

    log local0. "[IP::client_addr]:[TCP::client_port] -> [clientside {IP::local_addr}]:[clientside {TCP::local_port}] -> [IP::remote_addr]:[TCP::remote_port]"

     

    }

     

     

    As for the second part, as Nitass said, logging is a good starting point.

     

     

    Hope this helps,

     

    N
  • thanks nathan. 🙂

    Angelo,

    you may add more information in log.

    e.g.

    [root@ve10:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.19.79:80
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve10:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
       set uri [HTTP::uri]
       switch -glob [string tolower $uri] {
          "/uri1*" { pool pool1 }
          "/uri2*" { pool pool2 }
          "/uri3*" { pool pool3 }
       }
    }
    when HTTP_RESPONSE {
       log local0. "[IP::client_addr]:[TCP::client_port] -> [clientside {IP::local_addr}]:[clientside {TCP::local_port}] -> [IP::remote_addr]:[TCP::remote_port] | uri: $uri | pool: [LB::server pool]"
    }
    }
    
    [root@ve10:Active] config  tail -f /var/log/ltm
    Jul 14 03:07:31 local/tmm info tmm[5111]: Rule myrule : 172.28.19.251:37297 -> 172.28.19.79:80 -> 200.200.200.101:80 | uri: /uri1 | pool: pool1
    Jul 14 03:07:34 local/tmm info tmm[5111]: Rule myrule : 172.28.19.251:37298 -> 172.28.19.79:80 -> 200.200.200.101:80 | uri: /uri2 | pool: pool2
    Jul 14 03:07:35 local/tmm info tmm[5111]: Rule myrule : 172.28.19.251:37299 -> 172.28.19.79:80 -> 200.200.200.101:80 | uri: /uri3 | pool: pool3
    
  • Angelo's avatar
    Angelo
    Icon for Nimbostratus rankNimbostratus
    guys i got the rule woking the problem is now that all the traffic is only going to the first pool
  • Angelo's avatar
    Angelo
    Icon for Nimbostratus rankNimbostratus
    I'm getting this from the logs

     

     

     

    Jul 17 21:11:04 tmm2 info tmm2[12177]: Rule /SOA/Irule_soa_dev : 10.200.201.14:53492 -> 10.211.184.100:443 -> 10.211.58.168:8111 | uri: /wccustom/ | pool: /SOA/pool1

     

    Jul 17 21:11:04 tmm info tmm[12175]: Rule /SOA/Irule_soa_dev : 10.200.201.14:53494 -> 10.211.184.100:443 -> 10.211.58.178:8111 | uri: /favicon.ico | pool: /SOA/pool1

     

     

    i don't know what this is /favicon.ico because it's not a uri defined..

     

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    favicon.ico is a request the browser makes automatically for display in the browser itself:

    http://en.wikipedia.org/wiki/Favicon

    Make sure to specify a default pool or use a OneConnect profile on the virtual server.

    
    when HTTP_REQUEST {
       switch -glob [string tolower [HTTP::uri]] {
          "/uri1*" { pool pool1 }
          "/uri2*" { pool pool2 }
          "/uri3*" { pool pool3 }
          default { pool my_default_pool}
       }
    }
    

    Aaron

  • Angelo's avatar
    Angelo
    Icon for Nimbostratus rankNimbostratus
    thanks guys everything is working you guys are LEGENDS