Forum Discussion
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
- Kevin_Stewart
Employee
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.
- Kevin_Stewart
Employee
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.
- Mukund_125243
Nimbostratus
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.
- Mukund_125243
Nimbostratus
FYI - any alternate suggestions using BigIP are welcome :) - Jason_X_186825
Nimbostratus
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.
- Kevin_Stewart
Employee
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.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com