Forum Discussion
Scott_Wozny_894
Nimbostratus
Jun 13, 2012Find and replace hostname strings in http payload
Dear iRule gurus,
First and foremost, I apologize for the length of this post. I've done a bunch of work on my own to get to this point and I just want to be sure all the relevant details...
Scott_Wozny_894
Nimbostratus
Jun 15, 2012Hi Aaron,
Thanks very much for the advice. It looks like the app is working through the F5 now. The techs still need to test it, but I was able to get everywhere in the app I could find so I think this was the answer. Much obliged.
Scott
In case anyone runs into this problem in the future, here is the final code for the iRule.
-----BEGIN IRULE CODE HERE-----
Translate the hostname of inbound requests from external name to
internal name and port
when HTTP_REQUEST {
if { [HTTP::host] equals "www.rsa.externaldomain.com"} {
log local0. "Replacing Host header [HTTP::host] with internalservername.internaldomain.com:7004"
HTTP::header replace "Host" "internalservername.internaldomain.com:7004"
}
}
when HTTP_RESPONSE {
Translate the redirect location from internal name (and port, if
applicable) to external name
if { [HTTP::header is_redirect]} {
HTTP::header replace Location [string map -nocase {internalservername.internaldomain.com:7004 www.rsa.externaldomain.com internalservername.internaldomain.com www.rsa.externaldomain.com} [HTTP::header value Location]]
log local0. "Replacing Location header internalservername.internaldomain.com with www.rsa.externaldomain.com"
}
Translate payload of response from internal name (and port, if
applicable) to external name
if { [HTTP::header "Content-Type"] starts_with "text/" } {
STREAM::expression "@internalservername.internaldomain.com:7004@www.rsa.externaldomain.com@"
STREAM::enable
log local0. "[IP::client_addr]:[TCP::client_port]: Enabled stream filter for internalservername.internaldomain.com:7004 -> www.rsa.externaldomain.com"
}
}
-----END IRULE CODE HERE-----
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