Forum Discussion
Rodney_Newton_7
Nimbostratus
Nov 08, 2006Change Host Value
All,
I am trying to do something I thought would be pretty simple but I am missing something... whenever I see a request for www.outsidedomain.com I need to change that to servername. When I see the response I need to flip it the other way. Here is what I tried but maybe I am going about this the wrong way.
when HTTP_REQUEST {
if { [HTTP::host] equals "www.outsidedomain.com" }{
HTTP::header replace host "servername"
log local0. "The header is [HTTP::header host] "
log local0. "The Host Value is [HTTP::host]"
} else {
log local0. "No Changes Made"
}
}
The HTTP::host entry in the log is the same as when it came in but the HTTP::header host is the value I set. I understand that I need a when HTTP_RESPONSE for the return traffic but I can't even get this first part to work. What am I doing wrong? Thanks.
- JRahm
Admin
I've seen in other posts that you can set the host itself with the HTTP::host command, though it doesn't appear to be supported in my version (9.1.2)when HTTP_REQUEST { if { [HTTP::host] equals "www.outsidedomain.com" }{ HTTP::header replace host "servername" HTTP::host "servername" log local0. "The header is [HTTP::header host] " log local0. "The Host Value is [HTTP::host]" } else { log local0. "No Changes Made" } }
- hoolio
Cirrostratus
I also thought 'HTTP::host mynewhost.example.com' would work, but it doesn't on 9.2.3 either.when HTTP_RESPONSE { if {[HTTP::is_redirect]}{ HTTP::header replace Location [string map { "oldhost.example.com" "newhost.example.com" } [HTTP::header value Location]] } }
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