Forum Discussion
Charlie_2_10323
Nimbostratus
May 15, 2009HTTP Respond Data replacing ?
Hi
I will rewrite response hostname.
HTTP_Response function well, but HTTP_Respond_Data not.
We have on Request and Respond site HTTPS access
Client is terminated by Big-IP
Also we get HTTPS response it is possible to replacing hppts_response_data?
Does someone know that? Or is my http_response_data fools?
Any help would be great.
when HTTP_RESPONSE {
HTTP::collect [HTTP::header Content-Length]
if { $target_pool == "blo.server" } {
set location [HTTP::header value Location]
log local0.info "Server-RESPONS"
HTTP::header replace Location [string map -nocase {"blo.server.com" "www.client.com"} [HTTP::header Location]]
log "BEFORE Replacing payload with new data."
}
}
when HTTP_RESPONSE_DATA {
set clen [string length [HTTP::payload]]
regsub -all "blo.server.com" [HTTP::payload] "www.client.com" newdata
log "Replacing payload with new data."
HTTP::payload replace 0 $clen $newdata
HTTP::release
}
- The_Bhattman
Nimbostratus
Hi Charlie, - tarsier_90410
Nimbostratus
You may want to check this thread: - Charlie_2_10323
Nimbostratus
Hello, chbhatt & tarsier - hoolio
Cirrostratus
It would be more efficient to use a stream profile and iRule to rewrite the response content compared with collecting the response payload. Here is a generic (untested) example. You could add your request URI rewriting logic to it.LTM configuration object requirements: - The virtual server must have an HTTP profile configured - The virtual server must have a blank STREAM profile configured - The virtual server must have a default pool configured iRule configuration requirements: - Debug can be enabled/disabled in the RULE_INIT event by setting ::rewrite_debug to 1 or 0 respectively. - Outside the RULE_INIT section, no other changes should need to be made. when RULE_INIT { Log debug messages to /var/log/ltm? 1=yes, 0=no set ::rewrite_debug 1 String to find in response headers and/or data set ::find "oldname.example.com" String to replace in response headers and/or data set ::replace "newname.example.com" } when HTTP_REQUEST { if {$::rewrite_debug}{log local0. "[IP::client_addr]:[TCP::client_port]: New HTTP request to [HTTP::host][HTTP::uri]"} HTTP::header remove "Accept-Encoding" if {$::rewrite_debug}{log local0. "[IP::client_addr]:[TCP::client_port]: Removing Accept-Encoding request header"} } when HTTP_RESPONSE { Rewrite Location header value in HTTP redirects if it contains the $::find string if {[HTTP::is_redirect] && [string tolower [HTTP::header "Location"]] contains $::find}{ Replace $::find with $::replace in Location header value HTTP::header replace Location [string map "$::find $::replace" [HTTP::header replace Location]] if {$::rewrite_debug}{log local0. "[IP::client_addr]:[TCP::client_port]: Updated location from [HTTP::header replace Location]\ to [string map "$::find $::replace" [HTTP::header replace Location]]"} } Rewrite the response body if the response type is text if { [HTTP::header "Content-Type"] starts_with "text/" } { Configure the find/replace strings STREAM::expression "@$::find@$::replace@" Enable the stream filter STREAM::enable if {$::rewrite_debug}{log local0. "[IP::client_addr]:[TCP::client_port]: Enabled stream filter for $::find -> $::replace"} } else { Disable the stream filter for non-text responses STREAM::disable } } }
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