Forum Discussion
Thomas_Schaefer
Nimbostratus
Jan 02, 2013How to change any occurrence of myhost.company.com to myhost-dr.company.com
Hi all and Happy New Year!
I have been struggling wth an issue regarding streams and changing text.
For disaster recovery testing, I have a set of virtual hosts that are EXACT copie...
What_Lies_Bene1
Cirrostratus
Jan 02, 2013The stream profile will not apply to HTTP headers but iRule commands could sort this out as you've suggested.
You can indeed use the stream profile to add text (through replacement).
HTTP Content-Length is automatically updated from v9.4.0.
Here's some sample code (note I'm searching for hostname/ not hostname so we don't get a match on hostname-dr;
You must assign a Stream profile (with no source or target strings specified) to the Virtual Server before you can use this iRule
when HTTP_REQUEST {
We don’t want to rewrite requests, only responses
STREAM::disable
Prevent compressed responses from the server – not required if the
compression is offloaded to the BIG-IP
HTTP::header remove Accept-Encoding
}
when HTTP_RESPONSE {
Only modify body data if the response type is text
if { [HTTP::header value Content-Type] contains "text" } {
Search for instances of hostname/ and replace with hostname-dr/
@ Is a delimiter at the start and end of each string
STREAM::expression {@hostname/@hostname-dr/@}
Apply and rewrite response
STREAM::enable
}
}
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