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 hostname of incoming and outgoing request for a single pool. (I have LTM 1600, v 9.4.5) Basically, it looks like this:
For a single pool, any incoming HTTP Request that have http://www.mycompany.com/* ===rewrite the hostname to ====> http://blogs.mycompany.com/* (the server must see blogs.mycompany.com and the client will continue to see www.mycompany.com -- I'm not doing a redirect)
The outgoing (the return) request (HTTP Response), need to rewrite the hostname back to the original name (http://blogs.mycompany.com/* ====rewrite the hostname to =====> http://www.mycompany.com/* (the LTM will intercept and rewrite the host header back to www for the client).
If I can this in a HTTP profile, that would be awesome. Would the iRule be as simple as this:
HTTP_REQUEST{
HTTP::host "blogs.mycompany.com"
}
HTTP_RESPONSE{
HTTP::host "www.mycompany.com"
}
I saw some Reverse Proxy examples but it looked like overkill for what I want to do. Will the iRule I show above work? (Or can I set it up in the F5 HTTP profile?)
Thanks in advance...
-frisco76: cool:
- hoolio
Cirrostratus
There isn't a host header in responses. The app would potentially include absolute references to the hostname in HTTP headers and the payload. - frisco76_104868
Nimbostratus
Hi hoolio, thanks for the response. I will take a look at the links you provided. - frisco76_104868
Nimbostratus
HI 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).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]"} } }
- hoolio
Cirrostratus
Hi Frisco,when HTTP_REQUEST priority 501 { if {$::hostname_rewrite_debug}{log local0. "New URL: [HTTP::host][HTTP::uri]"} }
- trx_94323
Nimbostratus
Interesting use case. Was there ever a solution that you don't mind sharing?
Thanks.
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