Forum Discussion

nelson_ge_10908's avatar
nelson_ge_10908
Historic F5 Account
Jan 31, 2005

How to log URL with iRule

I am load balancing 2 proxy servers with widecard vip and need to log the client IP and the URL with iRule. Does this rule look right?

 

 

when HTTP_REQUEST {

 

 

if {[IP::local_addr] equals 0.0.0.0}

 

 

log local7.info remote_addr URI::basename

 

 

}

 

  • nelson_ge_10908's avatar
    nelson_ge_10908
    Historic F5 Account
    Yes this help, thanks.

     

    The reason I put an "if" statement is for testing purpose.

     

    I think I only want to turn logging on when troubleshooting, and I don't want to log every single request, that wouldn't be too much to log.

     

     

    How would I modify the following line if I want to look for source_URL=www.xyz.com instead source_ip=1.2.3.4?

     

     

    if { [IP::addr [IP::local_addr] equals "1.2.3.4"] }
  • nelson_ge_10908's avatar
    nelson_ge_10908
    Historic F5 Account
    Sorry, I meant destination_URL=www.xyz.com instead source_ip=1.2.3.4?

     

    If there are multiple IPs tied to the single URL at destination, such as in 3DNS scenario, it would be easier to match URL than IP.
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    Pretty simple, you get at the destination Host via the [HTTP::host] command. So, in a rule:

     
     when HTTP_REQUEST { 
        if { [HTTP::host] eq "www.xyz.com" } { 
           pool xyz_pool 
        } 
     } 
     

    or if you want to get a little fancy:

     
     when HTTP_REQUEST { 
        if { [domain [HTTP::host] 2] eq "xyz.com" } { 
           pool xyz_pool 
        } 
     }