Forum Discussion

Gustavo_Lazarte's avatar
Gustavo_Lazarte
Icon for Nimbostratus rankNimbostratus
Sep 06, 2006

iRule Not working SIMPLE AND URGENT

The following iRules should send the .jpg traffic to 10.1.0.50

 

 

when HTTP_REQUEST {

 

if {[HTTP::uri] contains "206.112.74.148"}{

 

if {[HTTP::uri] ends_with ".jpg"}{

 

node 10.1.0.50 80

 

} else {

 

pool iwrewards

 

}

 

}

 

}

 

 

when I check the log on the cache server I am getting .CFM .ASP .PHP pages requests.

 

 

the default pool is edge (10.1.0.50). I wanted to make the default pool iwrewards so I do not have the cache server as the bottleneck of traffic and let the iRule send the jpg traffic to the cache server. But when I do that the iRule does not send any traffic to the cache server.

 

 

Thanks for all your help
  • Can you provide a few more details? Are you sure 206.112.74.148 is in the URI? Consider this:

     

     

    www.cisco.com/cco-login?username=xxy

     

     

    [HTTP::host] would return www.cisco.com

     

    [HTTP::uri] would return /cco-login?username=xxy

     

     

  • sorry for the iRule

     

     

    when HTTP_REQUEST {

     

    if {[HTTP::host] contains "206.112.74.148"}{

     

    if {[HTTP::uri] ends_with ".jpg"}{

     

    node 10.1.0.50 80

     

    } else {

     

    pool iwrewards

     

    }

     

    }

     

    }

     

     

    and I still get this traffic on my cache server

     

     

    211.99.136.26 - 10.1.0.50 80 GET /azenv.php - 404 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1)

     

    2006-09-06 18:51:56 59.39.139.226 - 10.1.0.50 80 GET /Default.asp - 302 HttpClient

     

    2006-09-06 18:51:56 59.39.139.226 - 10.1.0.50 80 GET /index_referal.cfm ReferalID=250&page=index.cfm

     

     

  • Basically your rule says if the requested host does not contain "206.112.74.148", use the default pool, which you say is 10.1.0.50. If someone makes a request with a DNS name rather than the IP address, the host name will not contain "206.112.74.148". For example if the name was www.mysite.com, and this name resolved to "206.112.74.148" a request to www.mysite.com would bypass your rule and the default pool would be used.

     

     

    Something like this is likely why all traffic is going to 10.1.0.50.

     

  • As I always recommend, add some log statements to find out where your logic is going bad.

    when HTTP_REQUEST {
      log local0. "Host: [HTTP::host]
      log local0. "Uri: [HTTP::uri]"
      if {[HTTP::host] contains "206.112.74.148"}{
        log local0. "Host contains 206.112.74.148"
        if {[HTTP::uri] ends_with ".jpg"}{
          log local0. "uri ends with .jpg"
          node 10.1.0.50 80
        } else {
          log local0. "uri doesn't end with .jpg"
          pool iwrewards
        }
      }
    }

    run your test traffic through the virtual and then look at the /var/log/ltm file. This should point out any changes you need to make to get your logic working correctly.

    And, once you have everything working, remove the log statements before you put this into production.

    -Joe