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

Mukund_125243's avatar
Mukund_125243
Icon for Nimbostratus rankNimbostratus
Oct 02, 2013

HTTP_request and HTTP_response in same irule?

Is it allowed to execute a single irule with a 'when HTTP_Request' and also a 'when HTTP_response' events? I believe in the situation I wish to implement, I can write 2 separate Irules and stack them ( I think I read on this site that they work in the order they are added in). But , I was just curious to know if I can write the 'when http_request' at the top as an event and after closing the loop, use a new when 'http_response' as second part of the irule.

 

If knowing the situation helps, the plan is to divert traffic to a specific node based on a header value in request, but for calls that don't have a header value, the big ip should round robin the connection and then add a header value to it during response based on the responding node.

 

6 Replies

  • It is absolutely possible, and perhaps desirable, to put all of your events into a single iRule.

    when CLIENT_ACCEPTED {
        ...
    }
    when HTTP_REQUEST {
        ...
    }
    when HTTP_RESPONSE {
        ...
    }
    when LB_SELECTED {
        ...
    }
    

    It's also worth noting that the order of the events in the iRule is not important.

  • the plan is to divert traffic to a specific node based on a header value in request, but for calls that don't have a header value, the big ip should round robin the connection and then add a header value to it during response based on the responding node.

     

    Just keep in mind that headers are generally not relayed by the client. In other wordsm if you send a header to a client browser, it will not send it back.

     

  • Thanks Kevin. I understand the headers are not going to come back with browser requests - but these are soap calls from a customized solution and I am working with the developers from other side to capture all headers, and preserve a designated one I insert in the subsequent calls. All of this is to mask the fact that an app we run does not share session ids between nodes so round robin breaks calls after login (that have just a valid session id) since they go to a different node. The workaround I proposed is to mark with special header 'tags' which will then be attached to their subsequent calls and I route using the irule to the correct node.

     

    • Jason_X_186825's avatar
      Jason_X_186825
      Icon for Nimbostratus rankNimbostratus
      Hi Mukund, I'm curious how your request & response tagging worked for you? As I have a similar requirement where by I need to log a SOAP request and and it's corresponding SOAP reply. The iRule I have works in Dev but when deployed into production the association is not maintained.
  • Your solution is fine if the downstream client is programmed to relay the header. You can alternately use a cookie if the client supports it.