Forum Discussion
Rosieodonell_16
Oct 10, 2018Cirrus
Possible Rewrite Issues
For the longest time we only had the APM licensed and not the LTM module. This prevented me from using rewrite profiles in my designs and infrastructure. For rewrites I used the following iRule:
when RULE_INIT {
Log debug output to ltm logs - 1=yes, 0=no
set rwdebug 0
}
when HTTP_REQUEST {
Set up variables for the irule and sets the default behavior of the STREAM profile. .
set chk_resp_rw 0
set rwdebug 0
set clientHost "externalname.domain.com"
set serverHost "servername.domain.com"
STREAM::disable
Below check if the http request is from the HOST and starting URI that requires the rewrite.
if {[string tolower [HTTP::host]] equals $clientHost} {
HTTP::header replace Host $serverHost
HTTP::uri /externalname/[HTTP::uri]
set chk_resp_rw 1
if {$rwdebug}{ log local0. "Host Rewrite: [HTTP::host] , Context URI = [HTTP::uri]"}
}
}
when HTTP_RESPONSE {
Check server response for rewrites
if {$chk_resp_rw}{
STREAM expression changes all references in the response payload with the desired rewrite
if {[HTTP::header value Content-Type] contains "text"}{
STREAM::expression @$serverHost@$clientHost@
STREAM::enable
if {$rwdebug}{ log local0. "response Rewrite done: "}
}
Check Location header for desired rewrite
if { [HTTP::header exists Location]}{
HTTP::header replace Location [string map -nocase {$serverHost $clientHost} [HTTP::header Location]]
}
}
}
Everything seemed to work fine until we purchased the licensing for the LTM module. I am trying to do the following rewrite:
https://externalname.domain.com -> https://servername.domain.com/externalname
Just wondering if this my irule no longer works because we have the LTM module or should i be using the rewrite profile?
No RepliesBe the first to reply
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