Hi 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