Forum Discussion
Pat_Miller_9897
Nimbostratus
Apr 23, 2009New pool or Virtual Server Connection from within HTTP_RESPONSE
In the code below, I see the log message redirect, But it will not call a new virtual or a new pool.
I have an inbound soap request, that I do not know what pool to send it to, My plan was to:
Send the URI headers to a pool to return the version So I can do a lookup. ( This is working )
From the Response look to see if its a redirect ( this works )
Do a select based on the Version ( This works )
Call a new pool or virtual server ( does not work )
I do not know if after I send the request to a new pool or virtual server if it can pickup the rest of the Data from the Client.
My remote sites do not all support 30x redirects for posts.
Many Thanks
Pat
when CLIENT_ACCEPTED {
set debug "1"
set esbi_count "1"
if $debug { log local0. "HTTP Rule int" }
}
when HTTP_REQUEST_DATA {
if $debug { log local0. "HTTP_REQUEST_DATA" }
}
when HTTP_RESPONSE {
if $debug { log local0. "ReSponse" }
if { [ HTTP::is_redirect ] } {
if $debug { log local0. "redirect" }
set esbi_count "1"
set Tenant_Version2 [HTTP::cookie tenant_VERSION]
if $debug { log local0. "before switch to $Tenant_Version2" }
switch $Tenant_Version2 {
v7_0 {
if $debug { log local0. "v7_0" }
virtual V_Apache2211
}
v8_0 {
if $debug { log local0. "v8_0" }
virtual V_SFTP_01
}
default { HTTP::redirect "http://www.somesite.com/very_bad_uri.php" }
}
} else {
if $debug { log local0. "no redirect" }
}
}
when HTTP_REQUEST {
if $esbi_count { log local0. "ReSponse bit set" }
if $debug { log local0. "HTTP Request Start" }
if $debug {log local0. "JSESSION: [HTTP::cookie JSESSIONID]" }
if $debug {log local0. "Default HOST: [HTTP::host]"}
set Tenant_Name ""
set Tenant_Version ""
set Tenant_URL ""
if $debug {log local0. "URI: [HTTP::uri]"}
if $debug {log local0. "Tenant Version before switch: $Tenant_Version"}
if $debug {log local0. "Tenant Name before switch: $Tenant_Name"}
pool P_test_vcookie
}
3 Replies
- Nat_Thirasuttakorn
Employee
I think you need to save original request in variable, and use HTTP::retry to accomplish this...
If I am not wrong your request is POST, you may need to save it in HTTP_REQUEST_DATA like this...
(- you may need to issue HTTP::collect command in HTTP_REQUEST event)
set request_original [HTTP::request][HTTP::payload [HTTP::header Content-Length]]
- pass the request to P_test_vcookie in the first round
- detect version and keep pool/virtual selection in variable
- once you are ready to connect to the real destination, use HTTP::retry. something like this
HTTP::retry $request_original
- then it will invoke HTTP_REQUEST again. now you can pick the right pool/virtual based on pool/virtual selection variable from previous step
Nat - Jay_Sawyer_1110
Nimbostratus
@ natty76 - the pool command in HTTP_RESPONSE will not work, will your suggestion hold true for the virtual command? - Nat_Thirasuttakorn
Employee
Actually, I meant to use HTTP::retry in HTTP_RESPONSE. Then HTTP_REQUEST will be invoke again.
you can use pool or virtual command at that point..(sorry for confusion)
Here is an example.
when CLIENT_ACCEPTED {
set firsttime 1
}
whe HTTP_REQUEST {
if { $firsttime } {
first time go to pool that helps the selection...
pool P_test_vcookie
assume all requests that fall here are POST
HTTP::collect [HTTP::header Content-Length]
} else {
eval $real_dest
reset firsttime so next request will be evalulate again...
set firstime 1
}
}
when HTTP_REQUEST_DATA {
set original_request [HTTP::request][HTTP::payload [HTTP::header Content-Length]]
}
when HTTP_RESPONSE {
if it is first time (or probably can verify from server address)
if { $firsttime } {
let say real destination has been selected
set real_dest "virtual V_Apache2211"
HTTP::retry $original_request
set firsttime 0
}
}
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
