Forum Discussion
frisco76_104868
Nimbostratus
Oct 29, 2009hostname rewrite
Hi all,
I want to throw a message out on the forum..this might not require an iRule (if we can do it without an iRule, that would be preferred method).
I need to be able to rewrite the h...
frisco76_104868
Nimbostratus
Nov 03, 2009HI hoolio, I wrote up the iRule I think that should work (I have not tested this yet...I'm hoping to test this early next week).
In a nutshell, on HTTP_REQUEST..I'm going to rewrite the HTTP host header from aaa.company.com to bbb.company.com and on the HTTP_REQUEST, if HTTP header "Location" exists, I'm going to rewrite Location value from bbb.company.com to aaa.company.com (Is that a valid task to rewrite the Location? Do I need to rewrite the hostname anywhere else?). Again, I don't know if this is going to work or not...
when RULE_INIT {
set ::external_hostname "aaa.company.com"
set ::internal_hostname "bbb.company.net"
Enable debug logging to /var/log/ltm. 1 = yes, 0 = no
set ::hostname_rewrite_debug 0
}
when HTTP_REQUEST {
if {$::hostname_rewrite_debug}{log local0. "Original URL: [HTTP::host][HTTP::uri]"}
HTTP::header replace "Host" $::internal_hostname
if {$::hostname_rewrite_debug}{log local0. "New URL: [HTTP::host][HTTP::uri]"}
}
when HTTP_RESPONSE {
if { [HTTP::header value "Location"] starts_with "$::internal_hostname" }{
if {$::hostname_rewrite_debug}{log local0. "Inside of HTTP::header location, orig HTTP location equals: [HTTP::header location]"}
set ::location [HTTP::header location]
HTTP::header replace location $::external_hostname
if {$::hostname_rewrite_debug}{log local0. "Inside of HTTP::header location, new HTTP location equals: [HTTP::header location]"}
}
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
