Forum Discussion

velumanidevf5_2's avatar
velumanidevf5_2
Icon for Nimbostratus rankNimbostratus
Jun 04, 2018

iRULE to troubleshoot cookie

The application required stickness so we configured cookie presistance , sometimes its throwing 500 error page but its working perfectly with source_address presistance so we need to troubleshhot the cookie whether its keeping stickness .I want to log the floowing to troubleshoot , please help to correct me if its correct logic and syntax

 

1)log the client ip address and X-Forwarded-for 2)log whether request has "LB_PRODREG_PRD" cookie exist or not 3)log the request sent to which LB server 4log the resonse code and throw if the its has 500 error

 

  • when CLIENT_ACCEPTED {

     

    log local0. "[IP::client_addr]:[TCP::client_port]: New TCP connection to [IP::local_addr]:[TCP::local_port]" log local0. "X-Forwarded-For: [HTTP::header X-Forwarded-For]" }

     

    when HTTP_REQUEST {

     

    set hostvar [HTTP::host] set urivar [HTTP::uri] set ipvar [IP::client_addr] if {[HTTP::cookie exists "LB_PRODREG_PRD"]}{

     

    log local0. "[IP::client_addr]:[TCP::client_port]: Request with persistence cookie [HTTP::cookie value "LB_PRODREG_PRD"] to [HTTP::host][HTTP::uri]"

     

    } else {

     

    log local0. "[IP::client_addr]:[TCP::client_port]: Request contains NO persistence cookie to [HTTP::host][HTTP::uri]" }

     

    }

     

    when LB_SELECTED {

     

    log local0. "[IP::client_addr]:[TCP::client_port]: Request sent to [LB::server]"

     

    }

     

    when LB_FAILED {

     

    log local0. "[IP::client_addr]:[TCP::client_port]: Request failed to [LB::server]"

     

    }

     

    when HTTP_RESPONSE { set responsecode [HTTP::status] log local0. "Response code is $responsecode" if { [HTTP::status] eq 500 } { log local0. "$ipvar requested $hostvar $urivar and received a 500 from [IP::server_addr]" } }

     

  • In general they look OK. Move following line:

     

    log local0. "X-Forwarded-For: [HTTP::header X-Forwarded-For]"

     

    under HTTP_REQUEST event.

     

  • I don't see any loop scenario. There is always some CPU cycle utilized with iRule execution. After your troubleshooting efforts, you should detach iRule.