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...
hoolio
Cirrostratus
Nov 04, 2009Hi Frisco,
A few notes:
- This line won't log the updated host header value as the HTTP::host value is cached within the same event and event priority. If you want to log the Host header update, you can add a second HTTP_REQUEST event after the first:
when HTTP_REQUEST priority 501 {
if {$::hostname_rewrite_debug}{log local0. "New URL: [HTTP::host][HTTP::uri]"}
}
- The Location header value is normally an absolute URL like http://www.example.com/path/to/file.ext. So you would want to check for a Location header value which starts with http://$::internal_hostname or https://$::internal_hostname. Also, when rewriting the Location header value, you would want to do an in place replacement of $::internal_hostname for $::external_hostname--not just replace the Location header value with $::external_hostname. You can do this using:
HTTP::header replace Location [string map -nocase "$::internal_hostname $::external_hostname" [HTTP::header Location]]
The internal hostname might be included in links or other references in the response content. If that's the case, you would want to use a stream profile and STREAM::expression based iRule to rewrite the response payload. The wiki page for STREAM::expression has some examples for this.
Aaron
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
