Forum Discussion
Marek_George
Nimbostratus
Jul 23, 2010prefix based pool selection with content rewriting
Hi,
I use one virtual server and several backend systems (pools). The requested uri contains a prefix,
that me allow to set the right pool when the request was send to bigip. For further requests I must
rewrite the content from the specific backend system and insert the prefix.
Something going wrong!
Requests and responses are not rewritten correctly. The bigip mixed requests and responses.
Example: Requested was "/GSRV-SRV1" and the response was processed for "/GSRV-SRV2".
Where is the problem?
Version: BIG-IP 9.3.1 Build 81.1
when HTTP_REQUEST {
set SRVResponse ""
switch -glob [string toupper [HTTP::uri]] {
"/GSRV-SRV1*" {
discard the prefix
HTTP::uri [string range [HTTP::uri] 10 end]
set SRVResponse "/GSRV-SRV1"
pool myServer1
}
"/GSRV-SRV2*" {
HTTP::uri [string range [HTTP::uri] 10 end]
set SRVResponse "/GSRV-SRV2"
pool myServer2
}
"/GSRV-SRV3*" {
HTTP::uri [string range [HTTP::uri] 10 end]
set SRVResponse "/GSRV-SRV3"
pool myServer3
}
}
}
when HTTP_RESPONSE {
catch the content
set content_length 0
if { [HTTP::header exists Content-Length] } { set content_length [HTTP::header Content-Length] }
else { set content_length 2000000 }
if { $content_length > 0 } { HTTP::collect $content_length }
}
when HTTP_RESPONSE_DATA {
switch $SRVResponse {
"/GSRV-SRV1" {
do something like rewriting
}
"/GSRV-SRV2" {
do something like rewriting
}
"/GSRV-SRV3" {
do something like rewriting
}
}
}
- Hamish
Cirrocumulus
Without looking too closely, I'd suggest you put some logs in your code while developing so you can tell what it's doing and why... - hoolio
Cirrostratus
Hi Marek,when HTTP_RESPONSE { Only check responses that are a text content type (text/html, text/xml, text/plain, etc). if { [HTTP::header "Content-Type"] starts_with "text/" } { Get the content length so we can collect the data (to be processed in the HTTP_RESPONSE_DATA event) Limit collection to 1Mb (1048576 minus a little to spare) - See SOL6578 for details if { [HTTP::header exists "Content-Length"] } { if { [HTTP::header "Content-Length"] > 1048000 }{ Content-Length over 1Mb so collect 1Mb set content_length 1048000 } else { Content-Length under 1Mb so collect actual length set content_length [HTTP::header "Content-Length"] } } else { Response did not have Content-Length header, so use default of 1Mb set content_length 1048000 } Don't collect content if Content-Length header value was 0 if { $content_length > 0 } { HTTP::collect $content_length } } } ...
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